Vim Cheetsheet

By   10-05-2017 · 3 minute read · 520 words

Learning about jumplist

Issue was trying to get back to a previous location in a file after jumping to it. Still jump movements but they should help you move a bit more efficiently.


Clear line and drop into insert mode

Wow, this one is really cool, I usually just want to nuke a line and go right into insert mode. Instead of dding and then going back up and line and going into insert mode you can just use S


Don’t auto close brackets.

If you are using a plugin such as auto pairs, sometimes you don’t want it to auto-close after you open a brace.

ctrl + v

Navigate to the 3rd word ahead:


Navigate to the beginning of text on the current line:


Navigate to the first line:


Jump back to a previous location:

ctrl + o

Jump back to next location:


Go to last line in file:


Go to matching parenthesis or brackets



Navigate to a previous search result:


Searching backwards for the word “carmen”



Re-do changes:

ctrl + r

Change to the end of the line. Not sure if it’s more efficient to use c$ over C, regardless it’s two keystrokes.

C or c$

Replacing a string good with bad on the current line:


Delete a word with a leading space. See diw for just deleting a “inner” word.

Text objects


Moving back a word


Delete everything inside []


Navigating between splits - I was frustrated for a long time when a help screen would open and I don’t know how to close it.

ctrl-w + j

Writing to a file when you don’t have write permissions

This one was from peep code. Say you open a file and edit it only realizing that you need to be root to write to it. Instead of saving the file to something like /tmp then copying it back over the original file with higher elevated privileges, you can do all this with one single command.

:w !sudo tee %

The % here expands to the current file name

Regex search and replace


% - search the current buffer
g - search for all occurrences.
c - ask for confirmation `

Visual mode


Capital V is line wise selection/copy.


This is letter by letter visual selection.



Paste before current line.

Change mode

Instead of y to yank or d to delete you can use c to “change” text. This is useful because it deletes the text and puts you into insert mode immediately.

Moving code words


Move to the middle of a line


Repeating character jumps

I often confused character jumping with . which is repetition but instead using ; after a jump to repeat it. The , repeates the jump in the opposite direction.

Jumping to middle of screen



Add marks with ma then jump to it using `a

Editing text


Moving between sentences

Use either ( or ) to move between sentences. ( ) ```


comments powered by Disqus