User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

tips:linux:vitricks [2009/06/08 08:52] – created eriktips:linux:vitricks [2009/06/08 08:53] (current) erik
Line 1: Line 1:
 +====== Useful VI Tricks ======
 +Put this in your .vimrc:
 +  map <F5> :s.^//.. <CR> :noh <CR>
 +  map <F6> :s.^.//. <CR> :noh <CR>
 +Now you use a visual line select (''shift-V'') to select what you want to comment,
 +smack ''F5'' and it's done. ''F6'' uncomments.
 +As a bonus, use these to change indents. Change indent to your preference for
 +indenting. I use 4 spaces. Use ''\t'' if you want a tab. Combined with ''shift-V'', you
 +can move whole blocks left and right easily.
 +  map <F7> :s/^indent// <CR> :noh <CR> gv
 +  map <F8> :s/^/indent/ <CR> :noh <CR> gv