Thursday, November 11

I made a better vim cheat sheet.


you were looking!

I made a cheat sheet for my favorite text editor the other night. This is an improved version. More information, less clutter. It still needs some work, though. There's a lot of room to add stuff, depending on where the sheet will reside. I started it for a friend with a smallish Mac keyboard - it might need to be cut down for something like that. I recommend scissors.

This is only meant to be utilitarian, not complete or strictly correct.

move:                  move/act on:                search/jump:
                         end, begin word             /searchstring fwd
     ctrl-b              $,0 end, begin line         ?searchstring back
       k                 (,) sentence back, fwd      next searchstring
{ ( b h l w ) }          {,} paragraph back, fwd     '' go back 
       j                 ctrl-back, ctrl-fwd page    * word under cursor
     ctrl-f              fA goes to next "A"         % matching bracket
                         tA before next "A"          
insert text              change text
append text              yank text into buffer
Replace text             replace or substitute char
delete (kill) text       x kill char, X kill char back
dobj - dw, d$, etc.      undo, ctrl-redo, paste
dd clears whole line     . repeat last action
D to end of line         visual mode 
   :s/pattern/replacement/g - replace on this line (g for more than once)
  :%s/pattern/replacement/g - everywhere (g for more than once a line)

file ops:                    windows:
  :e file edit                 :new - new window empty
  :w file write                :split - new window on current
  :wq write and quit           :split file - new window with file
  :r file read contents        :vsplit - vertical split
  :r !command                  ctrl-w j,k to jump windows
  :q - quit buffer/window      ctrl-w +,-,= to size windows

format & misc tweaking:
  :set expandtab - use spaces  Join lines
  :set shiftwidth=4            gqobj - autoformat obj
  :set textwidth=70            ~ change case of char         
  :set nowrap                  >> << indent/unindent lines 

  nctrl-a, nctrl-x - inc or dec number under cursor by n