Vim (Vi Improved) is a modal text editor. The learning curve is a little steep but it offers many features that can make editing code faster.
I’ve been using Vim as my primary editor for a few years now and these are some of the tips and tricks to help increase your speed.
Vim can be overwhelming at first. To help you get your feet wet, here are some tips that will improve your productivity and make you faster at editing text.
Hit escape then to get into command mode, then use one of the following commands:
h- go left on line
j- go down a line
k- go up a line
l- go right on line
gg- go to the beginning of the file
gj- go down a screen
gk- go up a screen
G- go to the end of the file
w- to move forward one word at a time.
b- to move backward one word at a time
You can type text in insert mode, press
i to open insertion mode.
Vim has a steep learning curve, it just works different than other editors but with the benefit of speed.
If you are new to vim, I recommend these exercises
You can quickly switch case by pressing
~. Hold the key to repeat the action. Pretty cool feature
Vim lets you repeat actions. Pressing
50j moves down 50 lines,
50k moves up 50 lines. This works for any command,
5dd deletes 5 lines.
Not specifically vim, but it can boost your productivity. Letting you see more lines at once. You can see the different in the image below:
Press the keys
ddp to swap lines. It swaps the current line with the next one. Easy to switch lines, in case you may need it.
You can search for the word under the cursor. First move to the word you want to search for, then press
*. You can do this for any word. Pressing
# searches in reverse order.
It will help you with plugins and configure the default vim. Use your .vimrc to outline exactly what you want to happen every time you invoke vim.
You can search by pressing
/word. Then press
n to search for the next word. Your search can be longer than one word