Category Archives: vim

Learned new command in VIM

What I learn to use VIM today

Split A File
to split vim windows, in command mode:
:split filename
to navigate between windows
ctrl-w
or
ctrl-w

Copy A Block of Text
to copy a block of text:
go to the first line to copy, then type,
ma
BTW a in ma can be anything from b,c,d,e,….etc
then to the last line of the block to copy
y’a
Then go to the line to paste
p


To Replace Text
to replace text foo to bar in a line, go to the line type
:s/foo/bar 

to replace all foo to bar text, in a file
:%s/foo/bar/g

the g is to replace all occurrence, of foo

This is courtesy of
http://www.oualline.com/vim-cook.html#copy_block
http://www.vim.org/htmldoc/windows.html#window-move-cursor