Friday, October 19, 2007

Couple of things about VI

I'm now completely working on Debian and my true friends are vi and grep. Since Debian installations doesn't provide much of the things out of the box, we will have to configure most of them. Last week I was able to get syntax highlighting and tabs as spaces in my vi. If you want to save these settings permenantly put thse commands in .vimrc in your home(just $cd to get to ur home dir).
$cd
$vi .vimrc
(press i to get to insert mode for vi)
syntax on
:set expandtab
(pres ESC for command mode and type :wq to write and quit)

Now you are good to go.
Also in the vi command mode u can issue :set all to view all the possible options and :set to view your current configuration.

1 comment:

Dimuthu said...

And when tabs are replaced with spaces, you can control the number of spaces per tab(n) using
set tabstop=n
set softtabstop=n

This is useful, because c programmers prefer to set 4 spaces as the tab where as in ruby there is a conventions to put just 2 spaces.

And another thing in vim scripts. The way you put comments in there is quite uncommon
set tabstop=4 "this is a comment

Whatever put after double quote(") is a comment.