1. Alexander Q
  2. vim configuration


vim configuration / vimrc

set nocompatible
set modeline
filetype plugin on
filetype indent on
syntax on
let mapleader="\\"
let maplocalleader="\\"
set tabstop=2
set shiftwidth=2
set backspace=2
set scrolljump=7
set history=50
set ruler
set showcmd
set incsearch
set autoindent
set smartindent
set novisualbell
set showmatch
set t_vb=
set mouse=a
set ttymouse=xterm2
set scrolljump=1
set scrolloff=7
set sidescrolloff=5

" Haskell mode conceal is something I yet need to get used to. Disable all
" conceals for now.
set conceallevel=0

" fixes for screen
map  <Home>
map  <End>
imap  <Home>
imap  <End>

" Ctrl-G should work like in emacs
map <C-g> <Esc><Esc><Esc>
imap <C-g> <Esc><Esc><Esc>
xmap <C-g> <Esc><Esc><Esc>
smap <C-g> <Esc><Esc><Esc>
cmap <C-g> <Esc><Esc><Esc>

language messages C

" Color scheme
if has("gui_running")
colorscheme desert
set t_Co=256
colorscheme wombat256

" gvim stuff
"" toggle Menu and Toolbar
set guioptions-=m
set guioptions-=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>

" navigations between buffers
"" Alt+arrows
nmap <M-Left> <C-w><Left>
nmap <M-Right> <C-w><Right>
nmap <M-Up> <C-w><Up>
nmap <M-Down> <C-w><Down>

"" Binds to lower buffer
map <C-j> <C-W>j<C-W>_
map <C-k> <C-W>k<C-W>_
set wmh=0

" recoding
set fileencodings=utf-8,cp1251,cp866,koi8-r

"" <F8> File encoding for open
map <F8>	:execute RotateEnc()<CR>
vmap <F8>	<C-C><F8>
imap <F8>	<C-O><F8>

let g:encstring = "#koi8-r#cp1251#8bit-cp866#utf-8#"
function! RotateEnc()
	let y=-1
	while y==-1
		if !exists('b:encindex')
			let b:encindex=0

		let x=match(g:encstring,"#",b:encindex)
		let y=match(g:encstring,"#",x+1)
		let b:encindex=x+1

		if y==-1
			let b:encindex=0
			let str=strpart(g:encstring,x+1,y-x-1)
			return ":e ++enc=".str

"" <Ctrl+F8> File encoding for save (convert)
map <C-F8>	:execute RotateFEnc()<CR>
vmap <C-F8>	<C-C><C-F8>
imap <C-F8>	<C-O><C-F8>
function! RotateFEnc()
	let y = -1
	while y == -1
		if !exists('b:fencindex')
			let b:fencindex=0

		let x = match(g:encstring,"#",b:fencindex)
		let y = match(g:encstring,"#",x+1)
		let b:fencindex = x+1

		if y == -1
			let b:fencindex = 0
			let str = strpart(g:encstring,x+1,y-x-1)
			return ":set fenc=".str

"" encoding in modeline (for example "fileencoding=utf-8")
au BufReadPost * let b:reloadcheck = 1
au BufWinEnter * if exists('b:reloadcheck') | unlet b:reloadcheck | if &mod != 0 && &fenc != "" | exe 'e! ++enc=' . &fenc | endif | endif

"	status line
set statusline=%<%f%h%m%r\ %y%=ff=%{&fileformat}\ file=%{&fileencoding}\ enc=%{&encoding}\ %b\ 0x%B\ %l,%c%V\ %P
set laststatus=2

" Project settings
nmap <F12> <Esc>:Project<cr>
vmap <F12> <Esc>:Project<cr>
imap <F12> <Esc><Esc>:Project<cr>
let g:proj_run1="tabed %F"
nmap t <LocalLeader>1

" Scrolling binds
nmap <PageDown> <C-d>
vmap <PageDown> <C-d>
nmap <PageUp> <C-u>
vmap <PageUp> <C-u>

" perl-support tweaks
let g:perl_fold=1

" current directory is the directory of the file in current window
autocmd BufEnter * :lchdir %:p:h

map <C-S> :set ignorecase! ignorecase?<cr>
imap <C-S> <Esc><Esc>:set ignorecase! ignorecase?<cr>a

" mojo syntax highlight
let mojo_highlight_data = 1

" tab filename completion
set wildmode=longest:full
set wildmenu

" VCS binds
let g:VCSCommandDisableExtensionMappings = 1
let g:VCSCommandMapPrefix = "<Leader>v"
let g:VCSCommandMappings = [ [ 'd', 'VCSDiff'], [ 'D', 'VCSVimDiff' ] ]

" useful stuff from http://habrahabr.ru/blogs/vim/131951/
nnoremap * *N
nnoremap <C-H> :set hlsearch!<CR>
vnoremap * y :execute ":let @/=@\""<CR> :execute "set hlsearch"<CR>

" mouse
set mouse=

" numbers
set number
map <C-N> :set number!<cr>
imap <C-N> <Esc>:set number!<cr>i

" show tabs and trailing spaces
set listchars=tab:→\ ,trail:·
set list
map <C-P> :set list!<cr>
imap <C-P> <Esc>:set list!<cr>i

" Making <C-F> work in other modes
map <C-F> i<C-F><Esc>

" surround stuff
" surround key 'p' used for inserting <: _p('prompted text', 'surrounded text') :>
autocmd FileType xslate let g:surround_112 = "<: _p('\1context: \1', '\r') :>"
" surround key '-' used for inserting <: _('surrounded text') :>
autocmd FileType xslate let b:surround_45 = "<: _('\r') :>"
let g:Perl_MapLeader = ","

" tabs management
map [6;5~ :tabn<CR>
map [5;5~ :tabp<CR>
imap [6;5~ <Esc>:tabn<CR>i
imap [5;5~ <Esc>:tabp<CR>i

" haskell
au FileType haskell set expandtab
au FileType haskell compiler ghc
let g:haddock_browser = "/usr/bin/google-chrome"
let g:ghc = "/usr/bin/ghc"

" miscellaneous stuff stealed from perl-support vimrc
" autocomplete parenthesis, (brackets) and braces
inoremap  (  ()<Left>
inoremap  [  []<Left>
inoremap  {  {}<Left>
vnoremap  (  s()<Esc>P<Right>%
vnoremap  [  s[]<Esc>P<Right>%
vnoremap  {  s{}<Esc>P<Right>%
" surround content with additional spaces
vnoremap  )  s(  )<Esc><Left>P<Right><Right>%
vnoremap  ]  s[  ]<Esc><Left>P<Right><Right>%
vnoremap  }  s{  }<Esc><Left>P<Right><Right>%
" plugin taglist.vim : toggle the taglist window
" plugin taglist.vim : define the tag file entry for Perl
 noremap <silent> <F11>       :TlistToggle<CR>
inoremap <silent> <F11>  <C-C>:TlistToggle<CR>
let tlist_perl_settings  = 'perl;c:constants;f:formats;l:labels;p:packages;s:subroutines;d:subroutines;o:POD;k:comments'
let g:Tlist_Inc_Winwidth = 0