Vim: Key Keys

Published: 7 years ago web dev

For better or worse, I am making a significant effort to learn vim. No more shall I reach for the mouse to change some text or add a bracket! Ultimately my goal is not to necessarily stick with vim, but to be familar enough with its shortcuts to be able to switch to vim mode in another editor - perhaps Sublime. Perhaps even Visual Studio Code. Below are my notes on key keys, I plan to add to this as I learn new features of vim. I am also reading vim for humans, it focuses on making vim usable rather than teaching you the intricies and it is a good read if you want to be productive from the get-go. Along with this I did vimtutor which is a useful primer on vim shortcuts.

Navigation

  • j, k to navigate lines.

  • h, l to navigate characters.

  • w next word

  • b previous word

  • e end of word

  • % matching brace

  • gg top of document

  • G bottom of document

  • 123G go to line 123

  • CTRL + b page up

  • CTRL + f page down

Insert Modes

  • i to enter insert mode
  • a to enter append after current character
  • A to enter append at end of line

Deletion

  • dd delete line
  • x delete character

Replacement

  • r[c] to replace current character with [c]
  • R[c] to replace multiple characters with [c]

Search

  • /searchtext to search forwards

  • ?searchtext to search backwords

  • n to go to next item

  • :nc command to turn off case sensitivity

Undo and Redo

  • u to undo the last command
  • U to undo all changes to line
  • CTRL + r to redo

Copy and Paste

  • y for yank/copy
  • p for put/paste
  • v for visual selection

Misc

  • CTRL + W, then W to switch windows

Saving and quitting

  • :wqa save, close all windows and quit
  • :w FILE write out to file