Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 441 lines (313 sloc) 11.762 kb
" Eddie Kay <ichthyos@gmail.com>'s .vimrc
" Mostly copied from Brady Richards <brichards@athenahealth.com>
" Fix function/arrow keys in screen
set term=xterm-256color
":colorscheme asu1dark
:colorscheme manxome
" --------------------------------------------------------------------------
" | F key mapping
" | PuTTY sends oddly non-sequential keycodes by default...
" --------------------------------------------------------------------------
map [11~ <F1>
map [12~ <F2>
map [13~ <F3>
map [14~ <F4>
map [15~ <F5>
map [17~ <F6>
map [18~ <F7>
map [19~ <F8>
map [20~ <F9>
map [21~ <F10>
map [23~ <F11>
map [24~ <F12>
" --------------------------------------------------------------------------
" | UI related opions
" | most if not all taken from sven gukes
" --------------------------------------------------------------------------
" >> the : command line
" the completion key for the commandline
set wildchar=<TAB>
" crazy menu tab completion
set wildmenu
" Many shells allow editing in "Emacs Style".
" Although I love Vi, I am quite used to this kind of editing now.
" So here it is - command line editing commands in emacs style:
cnoremap <C-A> <Home>
cnoremap <C-F> <Right>
cnoremap <C-B> <Left>
cnoremap <C-E> <End>
cnoremap b <S-Left>
cnoremap f <S-Right>
cnoremap <C-H> <C-W>
" >> searching
" / searches will be case-insensitive unless they contain uppercase letters
set ignorecase
set smartcase
" fewer metacharacters in regexes will require \s. for more magic, use \v
set magic
" show the current first match
set incsearch
" >> information
" add the current buffer number to the file information that ^G gives
noremap <C-G> 2<C-G>
" show cursor position
set ruler
" show a report whenever any lines change
set report=0
" show a status line
set laststatus=2
" notify when in insert mode
set showmode
" in insert mode, show the current uncompleted command
set showcmd
" >> tabbing
" do vaugely c-style indents, but don't push lines that start with # to the beginning of lines
" TODO: i'd like >> to influence lines that start with #, but i don't know if it's possible
" indentexpr could do what i want if i fooled with it a little
set smartindent
"inoremap # X#
" everything tabby is 4 spaces
set tabstop=4
set shiftwidth=4
" >> misc
" let backspaces span just about anything
set backspace=2
" i don't like wrapping
set nowrap
" make ~ into an operator, and remap ~~ to act like ~
set tildeop
map ~~ ~ll
" map Y act like all the other upper case letter, i.e., to the end of the line
map Y y$
" let us move away from changed buffers without saving them
set hidden
" shortcuts to get around in grep and make lists
" i already have to ways to move up and down, don't need ^P and ^N as well
map  :cp<CR>
map  :cn<CR>
" this lets ^% and ^& move me backwards and forwards through buffers, just as ^^ moves
" me to the last buffer i was at
map  :bn<CR>
map  :bp<CR>
" & over a subrotine name acts like a primitive ctags for lookup of the function
" definition in that file
map & /^[ ]*\(sub\\|function\) \><CR>
map  :tag  <CR>
map  :pop<CR>
" add to the default autocomplete options the functions which AthenaUtils and
" athenalib.js define.
set cpt=.,w,b,u,t,i,k~/.vim/athena_complete.txt
if version >= 700
set cot=""
endif
" --------------------------------------------------------------------------
" | vimrc management
" |
" --------------------------------------------------------------------------
map ,e :edit ~/.vimrc<CR>
map ,s :source ~/.vimrc<CR>
map ,ns :call LoadFile( "~/.templates/script.pl" )<CR>
map ,ne :call LoadFile( "~/.templates/esp.esp" )<CR>
map ,nd :call LoadFile( "~/.templates/dml.pl" )<CR>
map ,nh :call LoadFile( "~/.templates/page.html" )<CR>
map ,n& :call LoadFile( "~/.templates/sub.pl" )<CR>
map ,nw :call LoadFile( "~/.templates/wizard.pm" )<CR>
map ,nt :set cpoptions-=a <CR>:r ~/.templates/tablespec.txt <CR>:redraw <CR> ?TABLENAME<CR>cw
function! LoadFile( filename )
set cpoptions-=a
execute ":0r " . a:filename
redraw!
endfunction
function! GetTaskComment( taskid )
/<enter description here>
execute "r!hydra_lookup.pl " . a:taskid
execute "normal kddi\<TAB>\<ESC>"
endfunction
command! -nargs=1 GetTaskCommentCmd :call GetTaskComment(<f-args>)
map ,h :GetTaskCommentCmd<SPACE>
function! ShowFuncName()
let lnum = line(".")
let col = col(".")
echohl ModeMsg
echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
echohl None
call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun
map ,f :call ShowFuncName() <CR>
" --------------------------------------------------------------------------
" | Function key management
" |
" --------------------------------------------------------------------------
map <silent> <F1> :call ManageFKeys()<CR>
map <silent> __ :help <CR>
function! ManageFKeys()
if exists("w:FKeysHelp")
echo w:FKeysMapset . " function keymap:\n"
echo w:FKeysHelp
echo "\n"
else
echo "No function keymap active.\n"
endif
echon "Possible map sets:\n" " 1) syntax - syntax highlighting\n" " 2) tags\n" " 3) p4\n"
let mapset = input( "Mapset: " )
if exists("w:FKeysMapset") && mapset != w:FKeysMapset
endif
if mapset == ""
return
elseif mapset == "syntax" || mapset == 1
let mapset = "syntax"
call FKeysSyntax()
elseif mapset == "tags" || mapset == 2
let mapset = "tags"
call FKeysTlist()
elseif mapset == "p4" || mapset == 3
let mapset = "p4"
call FKeysP4()
else
echo "\nUnknown mapping"
return
endif
echo "\nSet function keymap to " . mapset
endfunction
" --------------------------------------------------------------------------
" | Syntax highlighting
" |
" --------------------------------------------------------------------------
syntax on
let html_extended_events=1
let perl_extended_vars=1
"flag problematic whitespace (trailing and spaces before tabs)
"Note you get the same by doing let c_space_errors=1 but
"this rule really applies to everything.
highlight RedundantSpaces term=standout ctermbg=236 guibg=236
match RedundantSpaces /\s\+$\| \+\ze\t\|^\t*\zs \+\ze\t*\| \zs \+/ "\zs and \ze set start and end of match respectively
"use :set list! to toggle visible whitespace on/off
"set listchars=tab:>-,trail:.,extends:>
function! FKeysSyntax()
let w:FKeysMapset = "syntax"
let w:FKeysHelp = ""
let w:FKeysHelp = w:FKeysHelp . " F2: displays the name of the highlight class used to highlight the character under the cursor\n"
map <silent> <F2> :echo synIDattr( synIDtrans( synID( line("."), col("."), 0 ) ), "name" ) . " (" . synIDtrans( synID( line("."), col("."), 0 ) ) . ")" <CR>
let w:FKeysHelp = w:FKeysHelp . " F3: displays the name of the syntax class used to highlight the character under the cursor\n"
map <silent> <F3> :echo synIDattr( synID( line("."), col("."), 0 ), "name" ) . " (" . synID( line("."), col("."), 0 ) . ")" <CR>
let w:FKeysHelp = w:FKeysHelp . " F4: displays a summary of the syntax class used to highlight the character under the cursor\n"
map <silent> <F4> :exe "syntax list " . synIDattr( synID( line("."), col("."), 0 ), "name" )<CR>
"let w:FKeysHelp = w:FKeysHelp . " F5: toggle redundant whitespace coloring on/off\n"
"map <silent> <F5> :call ToggleHighlightRedundantSpaces()<CR>
let w:FKeysHelp = w:FKeysHelp . " F6: toggle syntax coloring on/off\n"
map <silent> <F6> mg:if has("syntax_items")<Bar>syn clear<CR>else<Bar>syn on<CR>endif<CR>`g
let w:FKeysHelp = w:FKeysHelp . " F7: replay last macro\n"
map <silent> <F7> @q
endfunction
" --------------------------------------------------------------------------
" | tagging
" |
" --------------------------------------------------------------------------
" set up the tags file
set tags=$ATHENA_HOME/perllib/Athena/tags,./tags
function! FKeysTlist()
let w:FKeysMapset = "tag"
let w:FKeysHelp = ""
let w:FKeysHelp = w:FKeysHelp . " F2: toggle taglist\n"
map <silent> <F2> :Tlist<CR>
let w:FKeysHelp = w:FKeysHelp . " F3: force sync of taglist\n"
map <silent> <F3> :TlistSync<CR>
endfunction
"let Tlist_Sort_Type = 'name'
"let Tlist_Auto_Open = 1
" --------------------------------------------------------------------------
" | P4
" |
" --------------------------------------------------------------------------
function! FKeysP4()
let w:FKeysMapset = "p4"
let w:FKeysHelp = ""
let w:FKeysHelp = w:FKeysHelp . " F2: filelog\n"
map <silent> <F2> :call P4FilelogCurrentBuffer()<CR>
let w:FKeysHelp = w:FKeysHelp ." F3: check out file to default changelist\n"
map <silent> <F3> :call P4OpenFileForEdit()<CR>
let w:FKeysHelp = w:FKeysHelp . " F4: annotate\n"
map <silent> <F4> :call P4AnnotateCurrentBuffer()<CR>
let w:FKeysHelp = w:FKeysHelp . " F5: full annotate\n"
map <silent> <F5> :call P4FullAnnotateCurrentBuffer()<CR>
let w:FKeysHelp = w:FKeysHelp . " F6: revert file\n"
map <silent> <F6> :call P4RevertFile()<CR>
let w:FKeysHelp = w:FKeysHelp . " F7: diff file against depot version\n"
map <silent> <F7> :call P4DiffCurrentBuffer()<CR>
let w:FKeysHelp = w:FKeysHelp . " F8: diff file against depot version, ignoring whitespace\n"
map <silent> <F8> :call P4DiffCurrentBufferIgnoringWhitespace()<CR>
let w:FKeysHelp = w:FKeysHelp . " F9: validate patch script\n"
map <silent> <F9> :!perl $P4_HOME/scripts/build/patch_harness.pl MAJ1 % --validateonly<CR>
let w:FKeysHelp = w:FKeysHelp . " F10: open file (//depot or not) under the cursor\n"
map <silent> <F10> :exe "e" substitute( "", "//depot", $P4_HOME, "" )<CR>
endfunction
function! P4FilelogCurrentBuffer()
let filename = expand( "%:p" )
new
exe "normal 1G!Gp4 filelog " filename "\n"
setlocal buftype=nofile
setlocal noswapfile
endfunction
function! P4AnnotateCurrentBuffer()
let filename = expand( "%:p" )
let linenumber = line(".") + 1
new
exe "normal 1G!Gp4 annotate " filename "\n"
exe "normal :"linenumber "\n"
setlocal buftype=nofile
setlocal syntax=perl
setlocal noswapfile
endfunction
function! P4FullAnnotateCurrentBuffer()
let filename = expand( "%:p" )
"let linenumber = line(".") + 1
new
exe "normal 1G!Gp4 annotate -a " filename "\n"
"exe "normal :"linenumber "\n"
setlocal buftype=nofile
setlocal syntax=perl
setlocal noswapfile
endfunction
function! P4DiffCurrentBuffer()
let filename = expand( "%:p" )
new
exe "normal 1G!Gp4 diff -du -dw " filename "\n"
set filetype=diff
setlocal buftype=nofile
setlocal noswapfile
endfunction
function! P4DiffCurrentBufferIgnoringWhitespace()
let filename = expand( "%:p" )
new
exe "normal 1G!Gp4 diff -duw " filename "\n"
set filetype=diff
setlocal buftype=nofile
setlocal noswapfile
endfunction
function! P4EditSpecForCurrentFile()
let filename = "/tmp/p4spec_" . expand( "%:p:gs?/?_?" )
let command = ":silent !perl -Mstrict -MP4 -e '"
let command = command . "my $change = new P4::Changelist( P4::PendingChangelists( CLIENT => $ENV{P4CLIENT}, FILE => $ARGV[0] ) );"
let command = command . " print $P4::Error || $change->Specification();"
let command = command . "' " . expand( "%:p" ) . " > " . filename
execute command
augroup P4SpecEdit
au!
execute "au BufHidden " filename " call P4CommitSpecForCurrentFile()"
execute "au BufHidden " filename " bdelete"
execute "au BufHidden " filename " au! P4SpecEdit"
augroup end
execute "new " filename
endfunction
function! P4CommitSpecForCurrentFile()
execute ":silent !p4 change -i <" expand( "%:p" )
redraw!
endfunction
" --------------------------------------------------------------------------
" | make: these two only apply to perl files
" |
" --------------------------------------------------------------------------
set makeprg=$HOME/bin/efm_perl.pl\ -c\ %\ $*
set errorformat=%f:%l:%m
run perforce.vim
call FKeysP4()
Jump to Line
Something went wrong with that request. Please try again.