Skip to content

Instantly share code, notes, and snippets.

Last active December 12, 2021 02:45
What would you like to do?
Vim shortcuts


  1. Normal
  2. Edit/Insert
  3. Visual
  4. Replace

Normal Mode

Alphanumeric keys can not be used to edit open code. We can use commands to manipulate content of open file.

This is default mode.


j - down

k - up

h - left

l - right

2k - Go 2 line up from cursor - Similar with other navigations

w - next word end

W - Next word start

e - End of the next word

b - last word

B - last word begin


/nginx - Find first occurrence of nginx after cursor

?nginx - Find first occurrence of nginx before cursor

Roaming the file

:12 - Go to line number

$ - Beginning of the current line

0 - end of the current line

G - go to last line

gg - go to first line

  • 2k - Go 2 line up from cursor
  • 5j - go 4 lines down from the cursor

Insert Mode

with i we can start using alphanumeric keys to edit our code/lines file

I - Insert at the beginning of the line/Goto beginning of the line

A - Append insert at the end of the line

a - append after at the cursor

i - Insert before at the cursor

Undo last change

ESC + u * keep going back to previous changes

Visual Mode

We can edit/select lines/code with commands without using mouse.

Enter into the visual mode: small v, capital V,

v - selects the characters -> up down left right

  • d to remove selected characted

V - selects the whole current line

  • d to remove selected lines

ctrl + v (not command + v of mac )- Enters into visual mode with first character selected only -> right + up + down

  • Useful to correct the multiple lines indentations


>> - shift right

<< - shift left

Multiple Lines indentation -> V + >>

Replace Mode

Same as visual mode, though we can replace patterns with this command.

R - Start replacing the characters from the cursor

r - replaces the current characted with entering into replace mode

Operators + Motion keys

c - change (paste) d - delete (probably cut) y - yank (copy)


c + w -> replace the current word + get into the insert mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment