"=============================================================================== "========== 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 gT nmap gt nmap tn :tabnew nmap tc :tabclose imap o nmap v :tabnew ~/.vimrc nmap h :tabnew ~/.vim/doc/mytips.txt 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 @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo') " Backspace deletes them nnoremap zd " And Space creates them in Visual. vnoremap zf " Make screen scrolling doable in Insert mode. inoremap inoremap " Make '' work like `` instead. map ' ` " Toggle hlsearch.. It is handy from time to time. map :set hlsearch! " Some C-Line mappings for faster directory navigation. cmap >v ~/.vim/ cmap >fn =expand('%:p') cmap >fd =expand('%:p:h').'/' " Let's stay in Visual mode after an indent. vnoremap > >gv vnoremap < to swap between MRU buffers. nmap " Source the ~/.vimrc file. nmap :so ~/.vimrc " Source the current file. nmap :so % "Bindings for faster buffer switches noremap :bp! noremap :bn! " Map F5 to toggle spelling (local function) map :call Speller() " does omnicompletion. inoremap " bd kills buffer, but preserves layout (local function) map bd :call Kwbd(1) " 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() " 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("") "}}} "}}} End Custom Functions