VIM Startup Guide


VIM is an editor for Linux systems. It is a powerful tool to edit files directly from the command shell.

To work with VIM, there are a few basic things you need to know, and you'll be able to manage yourself with VIM after you've read this.

Starting VIM

To edit a file in VIM, enter the filename at the command line.

Opening a file in VIM:
vim mysite/index.html

Commands or typing

VIM distinguishes between two different modes. This is the part of VIM that confuses most of the users for the first time. VIM starts in command mode.

In the command mode, all keys on your keyboard perform actions. You have to press i to switch to insert mode. In insert mode, the keys work like every normal text editor you're used to.

If you want to save a file, or quit VIM, you need to leave insert mode before you can type a command. This is done by pressing the Escape key.

If you get an error like No write since last change (add ! to override), you need to type :q! instead. This aborts any changes made to the file.

This is all you need to know to edit text files. The second tutorial reveals a lot of interesting key commands to make VIM an efficient editor.

Making VIM colorful

VIM is capable of a lot more, the screenshot below reveals this.

VIM ScreenshotVIM configured with a vimrc file.

The configuration file supports many options to customize VIM.

My vimrc file is available for download. It should be placed at ~/.vimrc for normal user accounts. To define global settings, use /etc/vimrc instead. Gentoo Linux places this file in /etc/vim/vimrc.

It's nicer to extend the configuration of your distribution instead. Don't overwrite the /etc/vimrc file, but place the new configuration at /etc/vimrc.local for instance. Edit the original /etc/vimrc file, and append the following line: source /etc/vimrc.local.

This reads the additional settings from the second configuration file, leaving the original configuration untouched.

Related articles

blog comments powered by Disqus