VI: Cool Tricks in VIM

Search For Text Beginning of Line
^\<word\>

Search For Multiple Words in a Line (remove spaces)
\(    \<word1\>    \|    \<word2\>    \)

Text Capture (search and replace sometext to sometextxt)

:%s#somete\(xt\)#somete\1\1#g

Replace only WHOLE WORDS (static & !statical)
:%s#\<static\>##g

Globally keep all lines containing the text "profile"
:g!/profile/d

Globally delete all lines containing the text "profile"
:g/profile/d

Globally delete all EMPTY lines in a file
:g/^$/d

Search for the word 'text' only at the end of a line
:text$

No comments: