Useful vi commands

Vi is a my preferred tool for editing files on Linux/Unix with a huge amount of possibilities. This blog post is a container for useful vi commands. Over the time the content will be extended by additional commands.

Show line numbers

To activate line numbers in vi, just use the following set command.

:set number

Copy & paste behavior

One of the annoying defaults of vi is the behavior of pasting text – containing lines starting with # – into a file. If vi finds a line starting with #, every following lines will be commented out. With the following set option, you can put vi in Paste Mode.

:set paste

Activating Paste Mode will also disable the Automatic Indentation feature.

Leave a Reply

Your email address will not be published. Required fields are marked *