Wednesday, May 10, 2006

A few cool vim tips

The "*" key will search for the word from the current cursor position to EOF
The "#" key will search for the word from the current cursor position to the top of the file.

/^[A-M]\+/ : search for lines beginning with one or more A-M
/you\|me : search for YOU OR ME

/\<\d\d\d\d\> : Search for exactly 4 digit numbers
/\<\d\{4}\> : same thing

:s%/,/\r/gc : To find and replace all commas with a new line

/^\n\{3} : find 3 empty lines
:%s/^\n\{3}// : delete blocks of 3 empty lines

:%s/^\(.*\)\n\1$/\1/ : delete duplicate lines

" Recording (BEST TIP of ALL)
qq # record to q
your complex series of commands
q # end recording
@q to execute
@@ to Repeat
5@@ to Repeat 5 times

Thats it for now.Rest later

No comments: