VIM Cheatsheet

14 days ago

Search and replace current file (same for Visual replacement)

%s/foo/bar/gi

Jump beginning or end of line and start insert


Beginning: I
End: A


Jump beginning or end of file


Beginning: gg
End: G

Redo
ctrl+^

Words


dw - delete word

b - jump word - beginning

e - jump word - end

Full screen navigation

gg - move cursor to first line

#G - move cursor to # line

GG move cursor to last line

CTRL+f - move cursor Forward full page

CTRL+b - move cursor Backwards full page

CTRL+u - move cursor Up half page

CTRL+d - move cursor Down half page

zt - move screen so cursor is at Top

zb - move screen so cursor is at Bottom

zz - center screen on cursor (very useful!)

ZZ - save document and quit (be careful!)

 

Multi Line Editing

Another approach is to use the . (dot) command in combination with i.

  1. Move the cursor where you want to start
  2. Press i
  3. Type in the prefix you want (e.g. vendor_)
  4. Press esc.
  5. Press j to go down a line
  6. Type . to repeat the last edit, automatically inserting the prefix again
  7. Alternate quickly between j and .

 

Lazyvim

NerdTree - Create file
a

Jump to function
gd

Toggle Formatter
<leader>uf

Dylan Hoogeveen Dylan Hoogeveen