domingo, 27 de febrero de 2011

My Vim configuration. Part 1 - View settings

Lately, I've been trying to understand better how Vim works, so I've started looking at its configuration files. I forked Chris's configuration (that was the easy part :D ) and I removed everything I'm not using at the moment. You can see my actual configuration files here.

It was not easy for me to understand how everything works, that's why I'm going to write about it :D Let's start from the beginning, the vimrc file.

.vimrc file
You can find an explanation about the .vimrc file here. Basically, this file is loaded just before entering Vim and it contains our personal Vim configuration settings.
I'll try to explain every line of my vimrc file during the week but, today, I'm going to show you how to configure the "view" part (colors, syntax highlighting, status line, etc).

My Vim view settings

" file syntax color on
syntax on
filetype on " enable file type detection
" colors
set t_Co=256 " use 256 colors
" show when you are in insert or visual mode
set showmode
" highlight the line containing the cursor
set cursorline
" show unwanted whitespace
set listchars=tab:-✈,trail:,extends:>
set list!
" fast terminal connection
set ttyfast
" show line numbers
set number
" status line
set showcmd " show status line
set laststatus=2 " show the status line always
set statusline=%f\ %(%m%r%h\ %)%([%Y]%)%=%<%-20{getcwd()}\ [b%n]\ %l/%L\ ~\ %p%%\ \
view raw .vimrc hosted with ❤ by GitHub

Now, we have a nice Vim window much more friendly than the initial one :D The only problem is that the color scheme is just the default one (which is not very good).

Adding color schemes to Vim
To add a color scheme to vim we first need to get one :D There are a lot of them. I'm actually using tir_black, but I have to try some more :D

Ok, you've selected one color scheme, how does Vim know about it? First of all, you need to create a .vim/colors directory in your home directory. Then, you have to copy the color scheme vim file to that directory.
That's all! Now, you can go to Vim and type

:colorscheme {your_color_scheme_name}
view raw gistfile3.vim hosted with ❤ by GitHub

The only problem with this is that it is not a permanent change. Every time you close Vim, it will lose your color scheme preference.
What can we do about it? Easy, we just need to open our .vimrc file and add the following line:

colorscheme tir_black " set color scheme
view raw gistfile2.vim hosted with ❤ by GitHub

Now, Vim knows our preferences :D

Ok, that's all for today. Soon on your screens "How to create shortcuts with Vim"

2 comentarios:

  1. Great one dude!

    I'm really looking forward to see the rest of your configuration.

    ResponderEliminar
  2. One of the best things about Vim is its user community. They have always been very helpful and patient, so it really lowers any learning barriers.

    Good luck!

    ResponderEliminar