Valid
	XHTML 1.1! Valid CSS!
Created 2010-08-06   Modified

images/book_uni.gif vi vim gvim home

../images/vim_on_fire.gif

# in command mode over text to do text searches.
number n yy to copy n lines, p to paste
Ctrl-v ESC for ^[ and Ctrl-v carriage return for ^M
w - from cursor to end of word including space (e - no space)
$ object from cursor to end of line
0 beginning of line
^ first non-blank
{ previous blank line
} next blank line
:set hlsearch highlight all searches
n+ or n- to go forward or backward in the file where n is a number
d delete
dd and p for deleting line and pasting line below cursor
r replace character under cursor
ctrl-f forward one screen
ctrl-b back one screen
ctrl-d forward half screen
ctrl-u back half screen
H   top of screen
M   middle of screen
L   end of screen
c for change eg cw
ctrl-g for position and file status
G for end of file
number-shift-g goto number
n| - goto column position n
/ and ? forward and backward searches n repeat, :set ic to ignore case % matching ([])
:#,#s/old/new/g replace between lines # and #
:%s/old/new/g replace whole file
:e to reload the file and :e filename to load a file

gvim for mac
function gvimmmac
{
    /Applications/Vim.app/Contents/MacOS/Vim -g $*;
}
$ gvimmac -S Session &

From David Land

:! to execute commands eg 
   :w temp.txt   write file to temp.txt
   :!ls -clt     see it
   :!rm temp.txt  remove it
   :!ls -clt     confirm removal

o and O - insert line below and above
shift+j to delete right of the cursor, deletes carriage returns!
n i x ESC to insert x n times before cursor

Vim options can be set in the .vimrc and .gvimrc file in the home directory.

:set nocindent
:set cino=e-2   :set shiftwidth=2     Changed indent for C++ as the default sux. See :h cinoptions.
set number - to set line numbers.
:set list - to show special characters, :set nolist

ctags generates a tags file containing definitions headers. :mak,

To load a session at startup
gvim -S Session.vim
:mksession! Session.vim
  make a Session.vim, ! to overwrite.
~   to toggle case.
ddp   swaps current and next line.
*p   put resister into document.
:reg %   display file name.

Spelling
:set spl=en spell
]s next forward
w= corrections

Three way diff
gvimdiff file1 file2 file3

Issues