From LQWiki
vim (vi improved) is a contemporary version of the classic vi editor, with additional capabilites.
Contents |
Introduction
All UNIX machines typically come with the vi text editor. However, vi lacks some more contemporary features (for example, syntax highlighting). This is where vim comes in. If you know how to use vi, you'll find vim to be the same except it has a number of useful features added to make editing easier. If you don't yet know how to use vi or vim, and you didn't come from using ed, you'll find the learning curve quite steep (which means, it might take you a while to learn to achieve maximum proficiency).
Vim was originally written by (and is still primarily maintained by) Bram Moolenaar. It started as a personal desire to have a useful vi-clone for the Amiga, but eventually grew as more features were added. It now runs on a variety of platforms (including Unix work-a-likes, e.g. GNU/Linux, Mac OS X, and *BSD; Amiga; Windows; Mac "Classic"; and OS/2) and supports a variety of graphical toolkits (including GTK, QT, and Carbon) in addition to the command-line interface. VIM is also the latin word for "power" or "force".
Vim has a compatibility mode which produces an almost vi-compatible experience (the version of vi used seems to be one released with Sun OS 4.x, from Version 3.7 dated on 6/7/85). This is enabled by using the ":set compatible" ex-command or by running Vim with the -C option.
Tips
~/.vimrc
To make a config file for vim, create a file in your home directory called .vimrc, and fill it with stuff that you'd normally type into vim's "ex" mode. For example, if you regularly do ":syntax on" from inside vim, put "syntax on" (no colon or quotes) on a line by itself in your ~/.vimrc file.
Here's the contents of a useful .vimrc file:
syntax on set number set expandtab set tabstop=4 set shiftwidth=4 set autoindent
Where:
- "syntax on" turns on syntax highlighting
- "set number" turns on line numbers
- "set expandtab" makes vim insert spaces (instead of tabs) whenever you hit the tab key
- "set tabstop=4" sets tabs to equal 4 spaces
- "set shiftwidth=4" makes it so when you use the text shifting command, it shifts over using 4-space indents.
- "set autoindent" has vim use "smart indenting", ie. when you are tabbed out to, say, the 8th column, and you type something then hit enter, the cursor is helpfully placed at the 8th column again for you.
(You can shut off line numbering from command mode by typing :set nonumber.)
syntax highlighting
You can turn syntax highlighting on/off with:
:syntax off :syntax on
If you have syntax highlighting on, but are using a dark background and the colors dont show up well, you can use this command:
:set background=dark
External links
- Vim Homepage (www.vim.org)
- #vim wiki (vi-improved.org)

This page is available under a