I’m not gonna lie. Starting Vim is hard.
It is partly because it is so much different from any other popular editor, and partly because it’s not very useful out of the box (though when configured properly it can easily replace ~put
So the newbies have to deal with lot’s of new concepts at the same time: how to use modes, how to navigate in the code, what configurations options should be used, and finally, and most importantly, how on earth I quit this thing?!
I remember all those problems very clearly, so here I’d like to share some piece of advice that can soften this harsh period a little bit for the Vim beginners. Because, in the end, it is all worth it.
Start with some basic configuration
The problem of Vim is that it’s not very useful out of the box. You need to work on the configuration a little bit in order for it to become useful. Some people find pleasure in this process of always polishing their
.vimrc (I certainly do), some don’t. But beginners sometimes are disappointed by how little Vim is offering out of the box. No syntax highlight, no code auto-completion, code formatting, etc.
There are several starter “packs” with all the blows and whistles that you can use right away. Personally though I don’t recommend this approach because of the downside – you never fully understand what’s in there and how to change it
Understanding and growing
So instead of starting with full-featured packs, I’d recommend starting with some small but sane
In order to learn what are the unlimited possibilities I highly recommend browsing through the other people’s configuration files. For example, you can browse the
Learn to love modes
When you first open Vim, you can’t type. If you try pressing the keys, something weird would happen. For example, you can accidentally move cursor to the next line, or most likely open some weird mode without any way to escape.
This is because at first you open a file in a NORMAL mode. This is the mode in which keys are used to execute commands, for example move to the next paragraph, format the file or delete the text till the and of a line. If you want to type you need the INSERT mode. There are multiple ways to get into it, but the most common is to just press
i (insert) in the normal mode.
There are several other modes as well but the point here is that modes are there to make
Don’t use arrows
Vim is very effective in terms of navigation. You can do anything without a mouse. But in order to get there you should limit yourself in some of the old habits and embrace the Vim’s way.
For example, in order to get to the beginning of the line, you can type
$, navigate to the beginning of the next word with
w (mnemonic word). go to the end of file with
There are many other shortcuts, which you can find on any tutorial site. But the point is you never really start using those and enjoy the high speed of your typing and navigation until you ban yourself from using arrows.
Thankfully, you can literals do just that with the following configurations:
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
This snippet literally disables your arrows, forcing you to
Embrace the motions
The keys I use the most are not
hjkl. Moving between code character by character is not very effective. The keys I used the most is
w (word) and
b which moves the cursor to the next/previous word.
gg will put my cursor to the beginning of the file,
G – to the end.
You can use
t<char> to move to the next char. For example,
f; will put the cursor on the next
t; will put just one character before it.
You can use
) to get to the next sentence and
}to move the paragraph. And there is a whole bunch of motions starting
]s will move to the next misspelled word,
]z moves to the next open fold, and there are many more (plugins can even add up to those)
Also all those you can prepend with a number. Say
5j will move you 5 lines
There are many and many more text motions. They let you be highly effective while moving through the code.
Combine Motions And Actions
In normal mode you can use some actions to modify text without going into the insert mode.
For example, you can type
x to delete a character under the cursor. You can prepend it with number:
5xwill delete 5 character. And finally, you can combine those actions with motions:
diw– delete the word under courser (mnemonic: delete in
– yank till w (copy into buffer text from the cursor till the next w character)
dG– delete the text till the end of the file
You get the idea. You can combine actions with motions, which opens up the infinite opportunities.
Vim From Scratch
I know starting with Vim is not easy, but I hope this little article helped you with some basics. And also give you the understanding that the gains definitely worth the effort.
If you’re willing to learn Vim and upgrade your productivity to the next level, you might be interested in this little video course I’m working on called “Vim From Scratch”.
The idea is to walk you through starting from
To get the latest news about it subscribe here👇
Where To Go From Here
- The best way to learn about something in Vim is to use the help, e.g.
to learn more about motions starting with ]. Help in Vim is properly structured and highly detailed.
- Learn from others by reading their dotfiles.
- Learn more about the Vim motions language
- On this very website there are other articles about Vim.