Some Vim Basics

This blog post is about some useful commands for the text editor Vim.

Show some technical infos about the current file like words, lines, ..

g + <Strg + g>

Search backwards from the current position


Forward search from the current position


Within the search mode, jump to the next match using the key n.

Search and Replace

Search the entire document and replace it with a specified string. The option g at the end of the command allows one to not just replace the first appearance of the search term, but any match.

:%s/<regex pattern to search for>/<replace by>/g

Search only the current line and replace it with a specified string:

:s/<regex pattern to search for>/<replace by>/g

To perform search and replace for multiple rows, select the area using and the arrow keys. Afterwards use the same syntax as for a single line.

Edit multiple lines

The following shortcuts are about appending a character to the beginning or the end of each line:

Append char '!' at the end of every line


Append char '!' at the beginning of every line



Vim Wiki: Search and Replace

Vim Wiki: Insert Text in Multiple Lines