keinerweiss.de
2022/04/16

vim for the lazy

vim alongside emacs are the most powerful editors on the linux terminal.

vi, or more specifically vim is pre-installed most of the time, sometimes even configured as standard editor.

vim can do anything you'd expect from a proper text editor without even looking at the mouse. This on the other hand causes a pretty steep learning curve when it comes to keyboard shortcuts.

If you you now and then "have to" use vim, this is the most basic shortcut cheat sheet that should get you through the day:

vim Cheat-Sheet for daily life

When opened, vim is always in command mode.

You cannot type yet.
Shortcut Effect in Mode
POS1 Go to first position in line nevermind
END Go to last position in line nevermind
DEL Remove character below cursor nevermind
Backspace Remove character to the left of the cursor nevermind
arrow keys move cursor around nevermind
i Edit text (interactive mode) command
v Mark text using the arrow keys (visual mode) command
y Copy marked text visual
d Delete marked text visual
ESC End interactive/visual mode. Back to command mode. interactive/visual
:q Close vim command
:q! Close vim even though you changed something. command
:w Save file command
:w FILENAME Save to a different file command
:wq Save file and close command
yy Copy current line command
dd Cut/Delete current line command
Shift+P Paste copied/cut line (above current line) command
u Undo last change command
Strg+r Revert last undo command
/TEXT Search for text command
n Jump to next search match command

Help! It's the old vi!

Especially the navigation keys cause weird output in vi (not vi improved) in interactive mode. Leave this mode with ESC before navigating. There are alternatives if the keys don't work at all.

Shortcut Effect in Mode
arrow keys h=left, l=right,
j=up, k=down
move cursor around nevermind command
POS1 0 (zero) Go to first position in line nevermind command
ENDE $ Go to last position in line nevermind command
ENTF x Remove character below cursor nevermind command

More knowledge also means more power!