Sunday, November 11, 2012

My .vimrc file

I use default vimrc file as a base for my own one. From vim you can get it with

:e $VIMRUNTIME/vimrc_example.vim

I always use tab expanding. So, usually a part of my .vimrc file looks like:

set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
set textwidth=80
Specific values for tabstop, shiftwidth and textwidth depend on project.

It is useful, especially during code review, to see not expanded tabs and trailing spaces. Leaving trailing spaces in code is bad idea, because they often mess diffs. To print these characters:

set listchars=trail:~,tab:>-
set list

Set colorschemes for GUI and console:

if has("gui_running")
    colorscheme wombat
else
    colorscheme wombat256
endif

Remove superfluous GUI elements

" remove toolbar
set guioptions-=T
" remove menu bar
set go-=m
" remove right-hand scroll bar
set go-=r

You can use second key mapping and switch between keymaps with CTRL-^ in insert mode, for example:

" remove toolbar
set guioptions-=T
" remove menu bar
set go-=m
" remove right-hand scroll bar
set go-=r

Set font for GUI:

set guifont=Ubuntu\ Mono\ 12
I use Ubuntu Mono or Monospace on Linux and Consolas on Windows.

No comments:

Post a Comment