VIM rc-file

August 10th, 2007 by exhuma.twn

Due to inane network restrictions I am maintaining several copies of my vimrc file. I would syncronize it though other means. Alas, the restrictions not only cover the network. So I have to resort to simply posting it here.

This is not meant to be an explanation of vim configuration file. However, it contains lots of comments, and might prove a good primer/starting-point. Eventually I will also include other modifications I made in my vim-home-folder as they are either used in the vimrc or just plain useful 😉

The .vimrc

" $Id$

set nocompatible           " Behave like vim and not like vi!

if has("vms")     "{{{ Stuff from (see bottom of file)
  set nobackup    " do not keep a backup file, use versions instead
   set backup      " keep a backup file

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

  augroup END


endif " has("autocmd") }}}

" VIM 7 Settings
" ----------------------------------------------------------------------------
if v:version >= 700
   set cursorline

" Indentation settings
" ----------------------------------------------------------------------------
set autoindent                   " always set autoindenting on
set shiftwidth=3                 " Force indentation to be 3 spaces
set tabstop=3                    "          -- idem --
set list                         " EOL, trailing spaces, tabs: show them.
set lcs=tab:" Tabs are shown as >·
set lcs+=trail:.                 " Trailing spaces are shownas periods
set expandtab                    " always expand tabs to spaces

" Development helpers
" ----------------------------------------------------------------------------
set showmatch                    " Show matching braces
   " for ctrl-P and ctrl-N completion, get things from syntax file
   autocmd BufEnter * exec('setlocal complete+=k$VIMRUNTIME/syntax/'.&ft.'.vim')
" Insert LGPL Header
imap <F1> <C-o>:r ~/.vim/licenses/LGPL.h<CR>
" Insert GPL Header
imap <F2> <C-o>:r ~/.vim/licenses/GPL2.h<CR>
" Insert indentation modeline
imap <F12> # vim: set shiftwidth=3 tabstop=3 expandtab ai:<CR>
" Map Meta-Left & Meta-Right to step through the error-list which is also used
" for vimgrep.
map <M-Right> :cn<CR>
map <M-Left>  :np<CR>

" Display
" ----------------------------------------------------------------------------
set title                        " display title in X.
set foldcolumn=4                 " display folds
set nowrap                       " Prevent wrapping
colorscheme blackbeauty
set background=dark

" UI Tweaks
" ----------------------------------------------------------------------------
" make search results appear in the middle of the screen:
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz
nmap <kMinus>  :bprevious<CR>    " Switch to previous buffer
nmap <kPlus>   :bnext<CR>        " Switch to next buffer
nmap <C-s>     :w<CR>
set backspace=indent,eol,start   " allow backspacing over everything in insert mode
set history=50                   " keep 50 lines of command line history
set ruler                        " show the cursor position all the time
set showcmd                      " display incomplete commands
set so=7                         " Keep a 7-lines lookahead when scrolling
set wildmenu                     " Show auto-complete matches
nnoremap Q gq                    " Don't use Ex mode, use Q for formatting

" Print Settings
" ----------------------------------------------------------------------------
set printoptions=header:3,number:y,left:10mm,right:10mm,top:10mm,bottom:10mm

" Abbreviations
" ----------------------------------------------------------------------------
iab miam Michel Albert <>

" EOF... sort of 😉
" good example at
" vim: set shiftwidth=3 tabstop=3 expandtab:
" vim: set foldmethod=marker foldmarker={{{,}}} foldenable foldlevel=0:

The .gvimrc

" Things to override for the GTK interface
" ----------------------------------------------------------------------------
colorscheme my_inkpot
map <F2> :colorscheme my_inkpot<CR>:set background=dark<CR>
set cmdheight=2                  " How many lines does the command-line occupy?
set mousehide                    " Hide the mouse pointer while typing
set guifont=Monospace\ 12

Posted in Babble, Coding Voodoo | 2 Comments »

  • John

    Thanks for the vimrc file. I have one problem with it though, that I’m not sure how to fix. I can’t seem to find the answer by googling it.
    When I launch vim, I get the following error:
    Error detected while processing BufEnter Auto commands for “*”:
    E15: Invalid expression: ’setlocal complete+=k$VIMRUNTIME/syntax/’.&ft.‘.vim’)
    E15: Invalid expression: (’setlocal complete+=k$VIMRUNTIME/syntax/’.&ft.‘.vim’)

    Any ideas how I can fix this?

    Here’s a piece of what vim –version outputs:
    VIM – Vi IMproved 7.0 (2006 May 7, compiled May 9 2007 18:57:32)
    Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-235, 237


  • exhuma.twn

    Try this:

    autocmd FileType *  execute "setlocal complete+="."k/usr/share/vim/vim62/syntax/".getbufvar("%","current_syntax").".vim"


Recent Posts