rendered paste body"===============================================================================
"========== CUSTOMIZATION (vimrc) ============================================
"===============================================================================
"
filetype plugin indent on
syntax enable
"===============================================================================
" Custom AutoCommands Start Here"{{{
"===============================================================================
" Markdown Autocmds
augroup markdown
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
augroup END
" Blogger Autocmds
augroup blogger
autocmd BufRead *.blogger set ai formatoptions=tcroqn2 comments=n:>
augroup END
" Mono Autocmds
autocmd BufRead,BufNewFile *.cs set softtabstop=8
autocmd BufRead,BufNewFile *.cs set shiftwidth=8
autocmd BufRead,BufNewFile *.cs set textwidth=130
" Vim Script Commands
autocmd BufRead,BufNewFile *.vim set foldmethod=marker
autocmd BufRead,BufNewFile .vimrc set foldmethod=marker
" DocBook Autocmds
autocmd BufRead,BufNewFile *.xml setfiletype docbk
autocmd BufRead,BufNewFile *.xml set softtabstop=2
autocmd BufRead,BufNewFile *.xml set shiftwidth=2
autocmd BufRead,BufNewFile *.xml set textwidth=78
" HTML Autocmds
autocmd BufRead,BufNewFile *.html set softtabstop=2
autocmd BufRead,BufNewFile *.html set shiftwidth=2
autocmd BufRead,BufNewFile *.html set textwidth=78
" TeX Autocmds
autocmd BufRead,BufNewFile *.tex set filetype=tex
autocmd BufRead,BufNewFile *.tex set textwidth=78
autocmd BufRead,BufNewFile *.tex set shiftwidth=4
" mytips.txt Autocmds
autocmd BufWrite mytips.txt :helptags ~/.vim/doc
autocmd BufRead mytips.txt set noreadonly
autocmd BufRead mytips.txt set modifiable
autocmd BufRead mytips.txt set filetype=help
"}}}
"===============================================================================
" Custom Variable Settings Start Here"{{{
"===============================================================================
if version >= 700
nmap <C-Y> gT
nmap <C-O> gt
nmap <leader>tn :tabnew<CR>
nmap <leader>tc :tabclose<CR>
imap <leader>o <C-X><C-O>
nmap <leader>v :tabnew ~/.vimrc<CR>
nmap <leader>h :tabnew ~/.vim/doc/mytips.txt<CR>
set dictionary=$HOME/.vim/misc/mydictionary
set thesaurus=$HOME/.vim/misc/mythesaurus
endif
" IMAPS Stuff
let g:Imap_PlaceHolderStart = '«'
let g:Imap_PlaceHolderEnd = '»'
let g:marker_prefers_select = 1
let g:marker_select_empty_marks = 0
"}}}
"===============================================================================
" Various Custom Settings Start Here"{{{
"===============================================================================
if has ("gui_running")
set cursorline
set guifont=Bitstream\ Vera\ Sans\ Mono\ 8
set guioptions=agirLt
endif
set t_Co=256
set hidden
set nostartofline
set autochdir
set formatoptions=qwantc1
set gcr=a:blinkon0
set mousemodel=popup_setpos
set mouse=a
set smarttab
set nosmartcase
set sessionoptions+=resize
set softtabstop=4
set expandtab
set backspace=indent,eol,start
set grepprg=grep\ -nH\ $*
set background=light
set incsearch
set autoread
set autowrite
set nohlsearch
set nocompatible
set autoindent
set laststatus=2
set scrolloff=3
set history=50
set ruler
set showcmd
set showmatch
set magic
set report=0
set shiftwidth=4
set tabstop=8
set wildmenu
set novisualbell
set nowrap
set linebreak
set foldlevelstart=0
set browsedir=current
set cmdheight=2
set wildmenu
set wildignore=*.bak,*.pyc,*.pyo,*.o,*.e,*~
set printoptions=left:8pc,right:3pc
"}}}
"===============================================================================
" Custom Key Mapping Start Here"{{{
"===============================================================================
" Make spacebar open and close folds.
nnoremap <Space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" Backspace deletes them
nnoremap <BS> zd
" And Space creates them in Visual.
vnoremap <Space> zf
" Make screen scrolling doable in Insert mode.
inoremap <C-E> <C-X><C-E>
inoremap <C-Y> <C-X><C-Y>
" Make '' work like `` instead.
map ' `
" Toggle hlsearch.. It is handy from time to time.
map <silent> <F12> :set hlsearch!<CR>
" Some C-Line mappings for faster directory navigation.
cmap >v ~/.vim/
cmap >fn <c-r>=expand('%:p')<cr>
cmap >fd <c-r>=expand('%:p:h').'/'<cr>
" Let's stay in Visual mode after an indent.
vnoremap > >gv
vnoremap < <gv
" Map <C-M> to swap between MRU buffers.
nmap <C-M> <C-^>
" Source the ~/.vimrc file.
nmap <F3> :so ~/.vimrc<CR>
" Source the current file.
nmap <F4> :so %<CR>
"Bindings for faster buffer switches
noremap <silent> <C-H> :bp!<cr>
noremap <silent> <C-L> :bn!<cr>
" Map F5 to toggle spelling (local function)
map <silent> <f5> :call Speller()<cr>
" <Ctrl-I> does omnicompletion.
inoremap <C-I> <C-X><C-O>
" <Leader>bd kills buffer, but preserves layout (local function)
map <silent> <leader>bd :call Kwbd(1)<CR>
" Replace :b with :Bs for running BufSel (local function)
cabbr b Bs
"}}}
"-------------------------------------------------------------------------------
" Custom Functions Start Here"{{{
"-------------------------------------------------------------------------------
" Speller: Turn on/off spellchecker."{{{
function! Speller()
if (&spell)
setlocal nospell
echo "Speller OFF"
else
setlocal spell spelllang=en_ca
echo "Speller ON"
endif
endfunction
" End Speller }}}
" TabMessage: Put output of ex commands in a new tab."{{{
function! TabMessage(cmd)
redir => message
silent execute a:cmd
redir END
tabnew
silent put=message
set nomodified
endfunction
command! -nargs=+ -complete=command TabMessage call TabMessage(<q-args>)
" End TabMessage }}}
" Kwbd: Kill the current buffer, but don't change the layout."{{{
function! Kwbd(kwbdStage)
if(a:kwbdStage == 1)
let g:kwbdBufNum = bufnr("%")
let g:kwbdWinNum = winnr()
windo call Kwbd(2)
execute "bdelete " . g:kwbdBufNum
execute "normal " . g:kwbdWinNum . ""
else
if(bufnr("%") == g:kwbdBufNum)
let prevbufvar = bufnr("#")
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != g:kwbdBufNum)
b #
else
bn
endif
endif
endif
endfunction
" End Kwbd }}}
" BufSel: Select from buffers matching a certain pattern (case insensitive)"{{{
" Case sensitivity can be altered by setting g:BufSel_Case_Sensitive
function! BufSel(pattern)
let buflist = []
let bufcount = bufnr("$")
let currbufnr = 1
while currbufnr <= bufcount
if(buflisted(currbufnr))
let currbufname = bufname(currbufnr)
if (exists("g:BufSel_Case_Sensitive") == 0 || g:BufSel_Case_Sensitive == 0)
let curmatch = tolower(currbufname)
let patmatch = tolower(a:pattern)
else
let curmatch = currbufname
let patmatch = a:pattern
endif
if(match(curmatch, patmatch) > -1)
call add(buflist, currbufnr)
endif
endif
let currbufnr = currbufnr + 1
endwhile
if(len(buflist) > 1)
for bufnum in buflist
echo bufnum . ": ". bufname(bufnum)
endfor
let desiredbufnr = input("Enter buffer number: ")
if(strlen(desiredbufnr) != 0)
exe ":bu ". desiredbufnr
endif
elseif (len(buflist) == 1)
exe ":bu " . get(buflist,0)
else
echo "No matching buffers"
endif
endfunction
command! -nargs=1 -complete=buffer Bs :call BufSel("<args>")
"}}}
"}}} End Custom Functions