My .vimrc

my very own vim config, with comments. suitable for perl, shell and c/c++ programming on UNIX systems

may need tweaks to use with python

works with xterm and urxvt

set nocp " disable vi combatibility
set tags+=~/.vim/systags " specify ctags file

set ch=1
set mousehide

" default/command-mode cursor is red, insert-mode is yellow
let &t_EI = "\<Esc>]12;red\x7"
if &term =~ "xterm" || &term =~ "rxvt"
let &t_SI = "\<Esc>]12;yellow\x7"
let &t_EI = "\<Esc>]12;red\x7"

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

let c_comment_strings=1 " highlight strings and numbers inside of C comments
if !exists("syntax_on")
syntax on " enable syntax highliting

set hls " Switch on search pattern highlighting.

" prev/next error
nmap <C-Up> :cprev<CR><Esc>
nmap <C-Down> :cnext<CR><Esc>

" some C-code reformatting to fit my taste
nmap <C-K><C-F> :%s/ )/)/g<CR>:%s/( /(/g<CR>:%s/\([^ ]\)(/\1 (/g<CR>:noh<CR>
" new empty tab
nmap <C-S-T> :tabe<CR>
" prev/next tab
nmap <C-S-Left> :tabp<CR>
nmap <C-S-Right> :tabn<CR>

" insert current year/month/day
imap \ymd <C-R>=strftime("%Y%m%d")<CR>

" for xterm16 colormap (only usable in xterm)
"let xterm16_colormap = 'allblue'

colo railscasts

" ci copies indent structure from existing lines
" sc shows entered command in the statusline
" wmnu enables visual completion list for vim commands
" nosol keeps the cursor in the same column if possible (after cross-line cursor movements)
" bs does some pretty backspace tweaks
" ls makes bottom statusline visible only when there's at least 2 windows
set ci sc wmnu nosol bs=indent,eol,start ls=1
" shm helps to avoid some "hit enter" prompts
" ww allows to move to next/prev lines when end/start of the line is crossed
set shm=Iat ww=<,>,[,]
" ts specified tabstop
" sw specifies shiftwidth
" tw specifies textwidth
set ts=4 sw=4 tw=0

" settings for list mode
set lcs=eol:$,tab:>-,trail:.,extends:>

" toggle taglist
nno <F3> :Tlist<CR>
" toggle hlsearch
nno <F4> :set hls!<bar>set hls?<CR>
" toggle line numbering
nno <F5> :set nu!<bar>set nu?<CR>
" inserting date
nno <F2> o<Esc>:read !date<CR>kJ$

" escape selected URI (perl support + URI::Escape module are required)
" it escapes whole strings.. if someone knows how to escape only selected text - please let me know
vmap <C-K><C-E> :perldo use URI::Escape; $_=uri_escape($_);<CR>

" some settings for TOhtml
let html_use_encoding="utf8"
let html_font="monospace"
"unlet html_use_css
let use_xhtml=1

" error format for perl -Wc (taken from perl.vim)
autocmd BufNewFile,BufRead *.p? set errorformat=
    \%-G%.%#had\ compilation\ errors.,
    \%-G%.%#syntax\ OK,
    \%m\ at\ %f\ line\ %l.,
    \%+A%.%#\ at\ %f\ line\ %l\\,%.%#,

autocmd BufNewFile,BufRead *.cgi set errorformat=
    \%-G%.%#had\ compilation\ errors.,
    \%-G%.%#syntax\ OK,
    \%m\ at\ %f\ line\ %l.,
    \%+A%.%#\ at\ %f\ line\ %l\\,%.%#,

" enable filetype plugins
filetype plugin on
" add filename to each match for grep
set grepprg=grep\ -nH\ $*

" some make cmd hotkeys
nmap <F9> :mak<CR>
nmap <C-F9> :mak install<CR>
" executes ./.exec file through sh
nmap <C-F10> :!sh ./.exec<CR>

" rebind cursor keys
" it makes cursor to jump to previous/next screen line instead of physical line
ino <Down> <C-O>gj
ino <Up> <C-O>gk
nno <Down> gj
nno <Up> gk

" make command mode work with russian keyboard layout
" to work with utf8 locale, this requires vim patch:
" (i use vim71-langmapmb-4.patch)
set langmap=ФA,ИB,СC,ВD,УE,АF,ПG,РH,ШI,ОJ,ЛK,ДL,ЬM,ТN,ЩO,ЗP,ЙQ,КR,ЫS,ЕT,ГU,МV,ЦW,ЧX,НY,ЯZ,фa,иb,сc,вd,уe,аf,пg,рh,шi,оj,лk,дl,ьm,тn,щo,зp,йq,кr,ыs,еt,гu,мv,цw,чx,нy,яz