When you start using vim you quickly find yourself searching for some small improvements on your keyboard commands. Maybe you want the <Esc> functionality a little bit closer to your fingers, or maybe you'd like to create a shortcut for a command sequence that you use very often.

There are good chances that you've checked stackoverflow looking for the easiest way to clear last search highlighting and found out that you need to type the command :nohlsearch or :noh , and then reading more, you get some tips about including a mapping (a shortcut!) on your .vimrc file, to have the shortcut ,<space> always under your fingers.

When ,<space> is pressed, the search highlighting is cleared

( from :help mapping …)

Key mapping is used to change the meaning of typed keys. The most common use is to define a sequence of commands for a function key.

It’s kinda easy to get going, to read the mapping that you’ve just pasted nnoremap ,<space> :nohlsearch<CR> and try to change it to something else… It’s fun to play a little bit and to figure it out by yourself, and you should do it, but mapping is something very present on vim, and it’s important to understand it.

As almost every single feature on vim, mapping is very powerful and it has tons of options and functionalities that handle many use cases but, as you might expect, on this post I'll try to expose the big picture of mapping, giving you a simple and clear understanding, bringing you the confidence to create your own mappings from scratch.