Vim Notes

Moving

  • w - move a word (only letters)
  • e - move to the end of a word (only letters)
  • b - move back a word (only letters)
  • W - move a word (moves until the next space)
  • E - move the end of a word (moves until before the next space)
  • B - move back a word (moves until the previous space)
  • 0 - move to the start of a line
  • $ - move to the end of a line
  • _ - move to the first word in a line
  • f<char> - move to the next occurrence of the char within the line
  • F<char> - move to the previous occurrence of the char within the line
  • ; - repeat the last motion

Inserting/Deleting/Changing

  • x - delete a character
  • s - delete a character and turn on insert mode
  • r - replace a character
  • o - insert one line down
  • O - insert one line up
  • I - insert at the start of the line
  • A - insert at the end of the line
  • ciw - change in word (turns on insert mode)
  • diw - delete in word (does not put in insert mode)
  • dd - delete current line
  • dj - delete current line and the one below
  • dk - delete current line and the one above
  • D - delete from cursor until the end of the line
  • <num>dd - delete <num> number of lines
  • R - enter replace mode

Copy (yank) and Paste

  • y - yank operator
  • yy - yank the current line
  • yw - yank from the cursor to the end of a word
  • p - paste (in case of yy it pastes on the line below)
  • P - paste on the line above

nvim-tree

  • a - create a new file on the current directory
  • d - remove a file
  • <leader>e - toggle tree
  • ^K - leader for nvim-tree
  • ^Wh - move left in tab
  • ^Wl - move right in tab
  • ^Wv - duplicate tab vertically
  • ^Wh - duplicate tab horizontally
  • ^Wc - close the tab

Cool Macros

To start recording a macro, type qa (for example). The actions you take next are going to be recorded until q is pressed again and stored in the a key variable (any letter can be used).

Reuse it later with: @a