Vim insert tips

To delete a word in insert mode, ctrl+w

Delete a character in insert mode, ctrl+h

Jump to the next line and remain in insert mode, ctrl+j

Paste in insert mode ctrl+a

Advertisements

Search and Replace in vim

To search and replace text in vim, change to command mode and you can do this;

%s/search/replace/gc

The above code will look for all the ‘search'¬†text in the current buffer and change them to ‘replace' text. The ‘gc' tells vim to look though the entire buffer and confirm the change before it replaces the text, if you leave out the ‘c’ it will change without needing a user’s confirmation.

Vertical split two files in gvim

These sites were useful.

http://donunix.blogspot.com/2008/01/vim-open-n-files-with-vertical-split.html
http://www.worldtimzone.com/res/vi.html
http://stackoverflow.com/questions/327411/how-do-you-prefer-to-switch-between-buffers-in-vim

:e filename – Edit a file in a new buffer
:bnext (or :bn) – go to next buffer
:bprev (of :bp) – go to previous buffer
:bd – delete a buffer (close a file)
:sp filename – Open a file in a new buffer and split window
ctrl+ws – Split windows
ctrl+ww – switch between windows
ctrl+wq – Quit a window
ctrl+wv – Split windows vertically