Saturday, June 5, 2010

.vimrc

Jeez when did this blog actually get content? Huh.

To balance out all that unwarranted productivity, have my .vimrc file. I'll update shortly with the ninja menu-creating skillz I learnt at work.
set guifont=Courier_New:h12
set title
set nobackup
set writebackup
set nohls
set visualbell
set ruler
set incsearch
set smartcase
set smarttab
set scrolloff=10
"set sidescrolloff=10
"set nowrap
set tw=80
set wm=0
set linebreak
set tabstop=2
set shiftwidth=2
set expandtab
set backspace=2
set noai
set nojoinspaces
set cpoptions-=a
set cinoptions=g0.5s,h0.5s,:0.5s,=0.5s,p0,(0.5s,+0.5s
set winminheight=0
"V6 set winminwidth=0
set matchtime=2
" eol:$,
set nolist
set lcs=tab:>-,trail:\
hi NonText ctermfg=4
hi SpecialKey ctermfg=4
syn on
filetype indent on
" winpos 0 0
" set lines=52 columns=80
set tags=~/.tags

if hostname() != ''
let &titleold = matchstr(system('whoami'), '\w\+') .'@'. hostname()
endif

" Darn F keys...
map OP
map OQ
map OR
map OS
map [11~
map [12~
map [13~
map [14~
map [15~
map [17~
map [18~
map [19~
map [20~
map [21~
map [23~
map [24~

" Printing
set popt=header:3,syntax:a,number:n
set printexpr=PrintFile(v:fname_in)
function! PrintFile(fname)
let pd = (&printdevice == '' ? '' : ' -d'. &printdevice)
call system('lp '. pd .' '. a:fname)
" echo 'lp '. pd .' '. a:fname
call delete(a:fname)
return v:shell_error
endfunc


" New ex commands
comclear
command -range=% CppCmt ,s/\/\*\([^\/]*\)\*\//\/\/\1/g
command -range=% CCmt ,s/\/\/\(.*\)$/\/\*\1 *\//g
command -range=% TidyEOL silent! ,s/\s\+$//g
" TidySrc is broken
command -range=% TidySrc silent ,TidyEOL | ,s/{\n\n\+/{
/ | ,s/\n\n\+\(\s\+\)}/
\1}/ | ,s/\n\n\n\+/


/ | normal "gg=G"
" :silent! TidyEOL
:silent! %s/{\n\n\+/{
/
:silent! %s/\n\n\+\(\s\+\)}/
\1}/
:silent! %s/\n\n\n\+/


/
gg=G
command -nargs=1 -complete=help Help :h | normal _
command -range=% MkLocalScript silent! ,s/set/setlocal/ | silent! ,s/map/map / | silent! ,s/ab/ab /



" Maps
map '1 gg
map # .n
" Comment a visual block
vmap # :s/^\(\s*\)\(.\)/\1# \2/:silent! '<,'>s/^\(\s*\)# #\s*/\1/
map '' :update
"map 'q :!rm -f .*.^^:q
map 'q :q
map 'Q :q!
map 'w '''q
map 'e :files:e
map 'E '''e
map '# :e #
map '~ '''#
map 'v :e ~/.vimrc
map '. :e %:p:h
map :update:prev
map :update:next
map 'r :e!%
map 'd :!rm %:set nomodified
" Updates a line like /# Last:/
map 'l 0f:"_C: :read !date +'\%Y.\%m.\%d \%T'kJ''
map L 10k
map M 10j
map S g$F r
map w _
map zi
map Z @q
map ] >>
map [ <<
nmap 1000000u
map :!irb


" New stuff
set fillchars=vert:\|,fold:\
set foldminlines=3
" set foldclose=all
"V6 set foldlevelstart=2
"V6 set foldmethod=indent
set viewoptions=folds,cursor

" F11: EditFtplugin(), F12: EchoFtPlugin
let vimdir = expand("~/.vim")
let ftdir = vimdir .'/ftplugin'
let skeldir = vimdir .'/skel'
function! EchoFtplugin()
if exists("b:file")
echo b:file ." sourced"
else | echo "No *.vim sourced"
end
endf
function! EditFtplugin()
if exists("b:file")
exec "edit ". b:file
elseif &ft != ''
let fn = g:ftdir .'/'. &ft
if isdirectory(fn)
exec "edit ". fn
else | exec "edit ". fn .".vim"
end
else | echo 'No filetype or b:file'
end
endf
map :call EditFtplugin()
map :call EchoFtplugin()

function! ReadSkel()
let full = fnamemodify(expand("%"), ":p")
let tail = fnamemodify(full, ":t")
let extn = fnamemodify(full, ":e")
let fn = g:skeldir ."/". tail
if filereadable(fn) | call ReadSkel_(fn) | return | end
let fn = g:skeldir ."/". extn
if filereadable(fn) | call ReadSkel_(fn) | return | end
let fn = g:skeldir ."/". &ft
if filereadable(fn) | call ReadSkel_(fn) | return | end
endf
function! ReadSkel_(fn)
exec "0read ". a:fn
silent! g/reated/normal 'l
endf


hi Comment ctermfg=6
hi Directory ctermfg=6
hi Folded term=standout ctermfg=7 ctermbg=0
ab LAL Alexis Lee

let @q = "I:silent! %s/ A\\n// 0\"wdd@w"

" usually unnecessary
filetype plugin on
augroup vimrc
au!

" Match any filename with at least one character
" Careful if /root/.vim -> /home/*/.vim, mkdir /root/.vim/view
au BufWinLeave ?* if &ft != 'mail' | mkview | end
au BufWinEnter ?* silent loadview

au BufEnter *.rbd setf ruby

au BufNewFile,BufEnter ~/winmvs*/* exec "so ".vimdir."/mvs.vim"
au BufNewFile ~/winmvs*/* call MvsGet()
au BufNewFile,BufEnter *.jcl setf jcl | exec "so ".ftdir."/jcl.vim"

" Do this properly sometime - test filename in cpp.vim
au BufEnter *.h exec "so ".ftdir."/h.vim"
au FileType xml setlocal ts=2 sw=2
au FileType help setlocal ts=2 sw=2
au FileType make setlocal ts=4 sw=4 list
au BufEnter sql/data/* setlocal ts=8 sw=8 list
" au VimEnter * au BufEnter * syn sync fromstart

au BufNewFile * call ReadSkel()
" au BufNewFile main.c call ReadSkel()

"au BufWritePost,FileWritePost *.pl normal :!chmod +x %
"au VimLeave *.pl normal :!chmod -R ugo+rx ~/perl/*.pl
augroup end

No comments: