Vim has two modes insertion mode and command mode. The editor begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode (where you can quit, for example by typing :q!). Most commands execute as soon as you type them except for "colon" commands which execute when you press the ruturn key.
:xExit, saving changes:qExit as long as there have been no changesZZExit and save changes if any have been made:q!Exit and ignore any changes
iInsert before cursorIInsert before lineaAppend after cursorAAppend after lineoOpen a new line after current lineOOpen a new line before current linerReplace one characterRReplace many characters
hMove leftjMove downkMove uplMove rightwMove to next wordWMove to next blank delimited wordbMove to the beginning of the wordBMove to the beginning of blank delimted wordeMove to the end of the wordEMove to the end of Blank delimited word(Move a sentence back)Move a sentence forward{Move a paragraph back}Move a paragraph forward0Move to the begining of the lineHMove to top of screenMMove to middle of screenLMove to botton of screen%Move to associated ( ), { }, [ ]
/strSearch forward for string?strSearch back for stringnSearch for next instance of stringNSearch for previous instance of string
Almost all deletion commands are performed by typing d followed by a motion. For example, dw deletes a word. A few other deletes are:
xDelete character to the right of cursorXDelete character to the left of cursorDDelete to the end of the lineddDelete current line:dDelete current line
The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command (below).
:s/pattern/string/flagsReplace pattern with string according to flags. (Example::%s/foo/bar/. Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.)gFlag - Replace all occurrences of patterncFlag - Confirm replaces.&Repeat last :s command
:w fileWrite to file:r fileRead file in after line:nGo to next file:pGo to previos file:e fileEdit file!!programReplace line with output from program
~Toggle upp and lower caseJJoin lines.Repeat last text-changing commanduUndo last changeUUndo all changes to line
Here's some key shortcut I use a lot with:
<C-^>switch current buffer with an alternative onezitoggle fold/unfold of current buffergdjump to definitionzzmake current line center of the screen