Wednesday, 9 May 2012
vim cheat sheet
To delete all lines containing "word" run the following
:g/word/d
To delete all lines that are empty or that contain only whitespace
:g/^\s*$/d
To delete all lines that do not contain a pattern, use g!. This command will delete all lines that are not comment lines.
:g!/^\s*"/d
Find the word "DOMAIN\" and replace with blank
:%s/DOMAIN\\//gc
Find ", " and replace with a cariage return \r
:%s/, /\r/gc
Delete the first 4 characters at the start of each line
:%s/^.\{4}//gic
Delete all trailing whitespace (at the end of each line) with:
:%s/\s\+$//
Delete all white space at the start of the line
:%le
or
:%s/^\s\+
Convert all UPPERCASE letters to lowercase
:%s/[A-Z]/\L&/g
Convert all lowercase letters to UPPERCASE
:%s/[a-z]/\U&/g
To sort alphabetically
:sort
Labels:
vim
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment