one's .vimrc is a subtle and precious thing.
" one's .vimrc is a subtle and precious thing
" tweakable defaults {{{
" right.
colorscheme evening
" don't blink the screen
set novb
" set the status line to look like 'ruler', plus buffer number at the end
set statusline=%<%f%h%m%r%w%y%=%l/%L,%c\ %P\ \|\ %n
" indent to 2
set tabstop=2
" indent to 2
set shiftwidth=2
" use lists when completing, the wildmenu is annoying
set wildmode=longest,list
" ctrl-n completion and such
set completeopt=menuone,longest,preview
" updatetime = 1 second. for lazy effects.
set updatetime=1000
" }}} tweakable defaults
" general {{{
" fully utilize vim
set nocompatible
" swap file dir
set directory=/var/tmp
" always show status line on every window
set laststatus=2
" insert spaces instead of tabs at start of line
set smarttab
set expandtab
" use a filetype-appropriate indent
filetype plugin indent on
" show matching parens
set showmatch
" ignore case on patterns (for searching, etc)
set ignorecase
" used with 'ignorecase', only ignore the case when all characters are lower
set smartcase
" backspace can backspace over anything
set backspace=2
" never wrap text by default
set nowrap
set textwidth=0
" use markers for folding, i hate all the other modes
set foldmethod=marker
" always try to use syntax hilighting
syntax on
" incremental search
set incsearch
" allow movement to another buffer without saving the current one
set hidden
" }}} general
" programming general {{{
" show an error window when there are errors
cwindow
" this is where my tags go
set tags+=.tags;/
" include dictionary in completion
set complete+=k
" use the syntax file at hand as the dictionary
au FileType * exe('setl dict+='.$VIMRUNTIME.'/syntax/'.&filetype.'.vim')
" include the directory tree in our path
exec "set path+=".substitute(getcwd(), ' ', '\\\ ', 'g')."/**"
" }}} programming general
" filetypes {{{
" none -> text {{{
"autocmd BufRead,BufNewFile *
" \ if &filetype == '' |
" \ setlocal filetype=text |
" \ endif
" }}} none -> text
" filetype text {{{
autocmd FileType text
\ setlocal autoindent |
\ setlocal textwidth=75 |
\ setlocal formatoptions+=tcan2 |
\ setlocal equalprg=fmt
" }}} filetype text
" filetype mail {{{
"autocmd FileType mail
" \ setlocal autoindent |
" \ setlocal textwidth=75 |
" \ setlocal formatoptions+=tcanq |
" \ setlocal comments=n:> |
" \ setlocal equalprg=fmt
" }}} filetype mail
" filetype markdown {{{
au! BufRead,BufNewFile *.mkd.* setfiletype mkd
au! BufRead,BufNewFile *.mkd setfiletype mkd
autocmd FileType mkd
\ setlocal autoindent |
\ setlocal textwidth=75 |
\ setlocal formatoptions+=tcan2wro |
\ setlocal comments=n:>
" }}} filetype markdown
" }}} filetypes
" maps {{{
" next/prev buffer
" tab in normal mode does a :bn buffer-next
nmap <TAB> :bn<cr>
" shift-tab in normal mode does a :bp buffer-prev
nmap <S-TAB> :bp<cr>
" mac terminal shift-tab
nmap [Z :bp<cr>
" tag browsing (enter: goto tag, backspace: up tag tree)
:au filetype,BufRead help :nnoremap <buffer><cr> <c-]>
:au filetype,BufRead help :nnoremap <buffer><bs> <c-T>
" make q format, and makes q not start useless macros
:map q gq
" turn on spell checking
:map <Leader>s :setlocal spell spelllang=en spellcapcheck=<cr>
:map <Leader>S :setlocal nospell<cr>
" delete the buffer; keep windows {{{
function Kwbd(kwbdStage)
if(a:kwbdStage == 1)
let g:kwbdBufNum = bufnr("%")
let g:kwbdWinNum = winnr()
windo call Kwbd(2)
execute "bd! " . 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
com! Kwbd call Kwbd(1)
" meta-w
nnoremap w :Kwbd<CR>
" option-w
nnoremap ‚àë :Kwbd<CR>
" }}} delete the buffer; keep windows
" }}} maps
" plugin-specific {{{
" otl options
let otl_bold_headers = 0
" Project {{{
let g:proj_window_width = 30
let g:proj_window_increment = 80
" m = ctrl-w_o and ctrl-w_ctrl-o persist the project window
" s = syntax highlighting in the project window
" t = toggle the window size, rather than increase by g:proj_widow_increment
let g:proj_flags = "mst"
nmap <silent> <Leader>p <Plug>ToggleProject<CR>
" }}}
" (un)commenting {{{
" toggle duplicate line and comment
nmap <c-c> <Plug>FtcDLAC
vmap <c-c> <Plug>FtcDLAC
imap <c-c> <Esc><Plug>FtcDLAC
" toggle commentify meta-c
nmap <m-c> <Plug>FtcTc
vmap <m-c> <Plug>FtcTc
imap <m-c> <Esc><Plug>FtcTc
" toggle commentify meta-c
nmap c <Plug>FtcTc
vmap c <Plug>FtcTc
imap c <Esc><Plug>FtcTc
" toggle commentify option-c
nmap ç <Plug>FtcTc
vmap ç <Plug>FtcTc
imap ç <Esc><Plug>FtcTc
" toggle commentify ctrl-/ (not mac terminal)
nmap <Plug>FtcTc
vmap <Plug>FtcTc
imap <Esc><Plug>FtcTc
" }}} (un)commenting
" }}} plugin-specific