set nocompatible " must be the first line filetype on filetype indent on filetype plugin on "autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete "autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1 "if you want rails support add the following in addition "autocmd FileType ruby,eruby let g:rubycomplete_rails = 1 "if you want classes included in global completions add the following "autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1 "autocmd FileType html set omnifunc=htmlcomplete#CompleteTags " saves and restores things like folds when closing a file au BufWinLeave * silent! mkview au BufRead * silent loadview au BufRead * set autoindent au BufWinEnter * silent set nopaste au BufWinEnter * set autoindent au BufWinEnter * set nu au BufWinEnter * silent set sw=4 au BufReadPost SCons* set syntax=python au BufReadPost *py set syntax=python au BufReadPost *rb set syntax=ruby au BufReadPost *html set syntax=html "au BufReadPost *py set complete+=k/home/mats/.vim/pycmpl/pydiction au BufReadPost *py vmap \em :call PythonExtractMethod()
"au BufWritePost *py set complete=k/home/mats/.vim/pycmpl/pydiction "au BufWritePost *py set complete+=k/home/mats/.vim/allwords "column of cursor set nocuc colo delek "for vim windows set noea set scs set nu set dict=/home/mats/.vim/allwords set expandtab set autoindent set history=50 set ruler set showcmd set incsearch set tabstop=4 set sw=4 set scrolloff=6 "set mouse= let NERDTreeIgnore=['\.vim$', '\~$', '\.pyc$'] command! -range Bash :!bash<Space>-c<Space>"`sed<Space>ne<Space>',<Space>p'<Space>%`" command! -range Tidy :,!tidy -iq --indent-spaces 4 -xml -omit -w 120 command! -range Filter :,!bash "MAPS map :!python % map .j|1
map :winc p map :Filter map :NERDTree:set nonu "map kj :set<space>cul!:set<space>cuc!:set<space>cul!:set<space>cuc! map g; map \s :Swap(0) map \S :Swap(1) map I#<Esc>j map I<del><esc>j map \ :w! /tmp/a map \ :w:Bash " map :let g:file=expand('%').'/'.getline('.') wincmd p exec ':e '.g:file map :tabp map :tabn map :q map :w map <S-Tab> map \ W imap <esc> imap <esc>a map \ :set invpaste map \f "syiw:Find<space>^Rs map \* "syiw:Grep<space>#s imap \\ ()<esc>i imap '' ''<esc>i imap "" ""<esc>i imap [] []<esc>i imap \ <Esc>:set invpastei imap :w imap #TO #TODO:<space> imap <esc>17h map :w map <space> 10j map #<space> 10k "LANGUAGE-RELATED imap ~try except:<Esc>Otry: imap ~init def __init__(self, imap ~im def (self,<Esc>hhhhhi imap ~ife if: else:<Esc>kA set path=.,** "set completefunc=rubycomplete#Complete "set omnifunc=htmlcomplete#CompleteTags set laststatus=2 set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P hi StatusLine ctermbg=7 ctermfg=0 gui=undercurl guisp=Yellow hi ModeMsg ctermbg=1 ctermfg=3 function! Grep(name) let l:pattern = input("Other pattern: ") "let l:_name = substitute(a:name, "\\s", "*", "g") let l:list=system("grep -nIR '".a:name."' * | grep -v 'svn-base' | grep '" .l:pattern. "' | cat -n -") let l:num=strlen(substitute(l:list, "[^\n]", "", "g")) if l:num < 1
echo "'".a:name."' not found" return endif echo l:list let l:input=input("Which?\n") if strlen(l:input)==0 return endif if strlen(substitute(l:input, "[0-9]", "", "g"))>0 echo "Not a number" return endif if l:input<1 || l:input>l:num echo "Out of range" return endif let l:line=matchstr("\n".l:list, "".l:input."\t[^\n]*") let l:lineno=matchstr(l:line,":[0-9]*:") let l:lineno=substitute(l:lineno,":","","g") "echo "".l:line let l:line=substitute(l:line, "^[^\t]*\t", "", "") "echo "".l:line let l:line=substitute(l:line, "\:.*", "", "") "echo "".l:line "echo "\n".l:line execute ":e ".l:line execute "normal ".l:lineno."gg" endfunction command! -nargs=1 Grep :call Grep("<args>") function! Find(name) let l:_name = substitute(a:name, "\\s", "*", "g") let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" | perl -ne 'print \"$.\\t$_\"'") let l:num=strlen(substitute(l:list, "[^\n]", "", "g")) if l:num < 1 echo "'".a:name."' not found" return endif if l:num != 1 echo l:list let l:input=input("Which ? (<enter>=nothing)\n") if strlen(l:input)==0 return endif if strlen(substitute(l:input, "[0-9]", "", "g"))>0 echo "Not a number" return endif
if l:input<1 || l:input>l:num echo "Out of range" return endif let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*") else let l:line=l:list endif let l:line=substitute(l:line, "^[^\t]*\t./", "", "") "echo "".l:line execute ":e ".l:line endfunction command! -nargs=1 Find :call Find("<args>") function! Swap(reverse) let l:chars = ',:()\[\]{}' let l:search = "[".l:chars."]" let l:reverse = a:reverse if l:reverse == 1 echo 'backwards' let l:col=search(l:search,"bW") exe "normal h" "echo col(".") endif let l:line=getline(".") let l:oldcol=col(".") "exe "normal f," let l:col=search(l:search,"W") let l:rightcol=col(".") "echo "first rightcol " . l:rightcol "exe "normal T," let l:col=search(l:search,"bW") let l:leftcol=col(".") "echo "first leftcol " . l:leftcol exe "normal l\"sd" . l:rightcol . "|" "we have the first word exe "normal " . (l:rightcol-(l:rightcol-l:leftcol)) . "|l" let l:leftcol=col(".")+1 "echo "second leftcol " . l:leftcol "exe "normal f," let l:col=search(l:search,"W") exe "normal \"td" . l:leftcol . "|" "we have the second word "echo "swapping " . @s . " and " . @t "do the pasting exe "normal h\"tPl\"sp" "echo "done" endfunction command! -nargs=1 Swap :call Swap(<args>) "refactoring function! PythonExtractMethod() range let name = inputdialog("Name of new method: ") let args = inputdialog("Argument list: ") '<
exe "normal O\def " . name ."(" . args . "):\<esc>" '> exe "normal o#return \\<esc>" normal >'< endfunction
Related Documents