My most used VIM regular expressions.

Delete all lines in a file except those that start with “#”. :g/^[^#].*$/d
Text search/replace. Transform line ‘wget http://gnucom.cc/some_backup.tar.gz’ into ‘/scripts/restorepkg some_backup.tar.gz’. This one is helpful for cPanel administrators. :%s/wget http:.*\//\/scripts\/restorepkg /g
Add something to the end of every line of a file. :%s/$/something/g
Add something to the beginning of every line of a file. :%s/^/something/g
This entry was posted in Webhosting and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.