10 useful vim shortcuts

I use these 10 vim shortcuts daily.


Typing gi in normal mode moves the cursor to the last place you were editing and instantly puts you in insert mode.

Ctrl+o and Ctrl+i

In normal mode, jumps to the previous (Ctrl+o) or next (Ctrl+i) place where cursor recently has been.

Ctrl+a and Ctrl+z

In normal mode, increment and decrement the number under the cursor. Additionally, the speeddating vim plugin makes these two shortcuts more powerful and you can also increment and decrement calendar dates under the cursor.

Ctrl+e and Ctrl+y in normal mode

In normal mode, scroll the current buffer one line up (Ctrl+e) or down (Ctrl+y).

Ctrl+e and Ctrl+y in insert mode

In insert mode, copy text character-by-character from the line below (Ctrl+e) or line above (Ctrl+y).

{ and }

In normal mode, go to previous/next paragraph.

>> and <<

In normal or visual mode, shift the line (or selection) one indent to the right (>>) or left (<<).

Ctrl+n and Ctrl+p

In insert mode, complete the current word under the cursor from the word following it (Ctrl+n) or words preceding it (Ctrl+p).


In insert mode, join the current line with the next line.

zz (two lowercase z’s in normal mode)

Center the buffer so that the current line you’re editing is in the middle of the screen.

ZZ (two capital Z’s in normal mode)

In normal mode, same as :wq!. Saves and exits vim.

Extra shortcut: vim sucks use emacs

See you next time!

Source link