Vim Tips

(external link) Vim is an amazing text editor.

Of course, when you start to use Vim it might seem quite difficult at the first glance. After a while though, when you know the basic functions to edit texts and get to know Vim's more advanced features you don't want to miss Vim any more.

I will not teach you how to use Vim - there are a lot of tutorials out there (see "More Information" below) - I will show you some configuration settings I find useful.

.vimrc

Here are some of the configuration settings that might not be standard (a line beginning with a quotation mark is a comment in .vimrc). You can also download my .vimrc[0] which includes even more settings. I have deleted bits of the file that are not interesting for you (like some abbreviations etc.).

.vim/filetype.vim

When you use syntax highlighting and Vim doesn't recognize the filetype you can set it manually by entering the command :setfiletype $filetype where $filetype stands for the actual filetype, e.g. html.

For example, if you save your HTML files with the file ending myending instead of html Vim probably won't recognize those files as HTML files. You could set the filetype manually each time you edit a file or you could automate this process:

" my ~/.vim/filetype.vim file

augroup filetypedetect
    au! BufRead,BufNewFile *.myending setfiletype html
    " more of these lines can follow...!
augroup END

More Information

You can get excellent information in the online help of Vim itself (within Vim type :help). On the (external link) official Vim Homepage there are also links to (external link) Vim Documentation. Be sure to have a look at the Vim Book! And there are even many more places - just browse the Internet!

To get started with Vim you should always begin with the (external link) vimtutor. Just start it and do what you're told :-)

(external link) Learning vi - the "cheatsheet" technique is a good ressource, too - as is the (external link) Vi Reference Card. Another (external link) VIM Quick Reference Card is even available in multiple languages.

[0] In Linux a program called wget is installed quite often. You can download my .vimrc and save it in your home directory with:

wget -O ~/.vimrc http://www.flof.at/2004/dot-vimrc

You're here: Vim Tips.
Last update: January 28, 2007

colors
(c) 2001-2008 Florian Fankhauser, http://www.flof.at/