The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
User:Coffnix/VIM Tips
Here are some uses within the text editor via the command line, VI:
Deletes multiple lines that start with certain characters:
:g/^ads/d
Delete determined no. of characters:
:g/^.\{44}/s///
Insert a character at the beginning of the line:
:%s/^/text/
or
:g/^/s//<insert>/g
Insert a character at the end of the line:
:%s/$/text/
or
:g/$/s//<insert>/g
Wrap the line based on a given separator:
:g/separator/s//^v^m/g
Insert the contents of the file at this point:
:r <file>
Replaces the first occurrence of characters in the file:
:g/<change>/s//<changed>
Replaces all characters in the file:
:g/<change>/s//<changed>/g
Replace (999
with (NULL
:
:s/([0-9][0-9][0-9]/(NULL/g
After selecting the information block, to indent with two spaces:
:s/^/
After selecting the information block, to indent with two spaces less:
:s/^ //
Delete all characters before the word "Typer" from the file:
:%s/.*\(Typer\)/\1
Delete all characters before the word "Typer" from a line:
:s/.*\(Typer\)/\1
Removes automatic line wrapping from VI:
:set nowrap
Read too: