" This is a modified example vimrc map gn :e ftp://amnoid.de/notes.txt set tabstop=4 set shiftwidth=2 set expandtab set enc=utf-8 set nocompatible set backspace=indent,eol,start set nobackup set history=100 set ruler set showcmd set incsearch set listchars=tab:>-,eol:$ set smartcase set ignorecase "without this, smartcase is ignored " let y and p use the system clipboard automatically (seems that this doesn't " work on all platforms) set clipboard+=unnamed " disable cursor blinking for drawing code debugging "set guicursor=a:blinkon0 if version>=700 " show cursorline in active window only set cursorline au WinEnter * set cursorline au WinLeave * set nocursorline au FocusGained * set cursorline au FocusLost * set nocursorline if has("gui_running") set tabpagemax=200 endif if has("autocmd") autocmd Filetype java setlocal omnifunc=javacomplete#Complete endif endif fun! ShowDoc(ident) let cmd1 = 'osascript -e ''tell application "XCode" to show document with apple_ref "//apple_ref/doc/c_ref/' . a:ident . '"''' let cmd2 = 'osascript -e ''tell application "XCode" to show document with apple_ref "//apple_ref/doc/man/3/' . a:ident . '"''' "echo cmd let res1 = system(cmd1) if res1 == "false\n" call system(cmd2) endif endfun map :call ShowDoc(expand('')) nmap h nmap j nmap k nmap l " sessions should restore gui window position and size as well set sessionoptions+=resize,winpos " Display last line even if it doesn't fit onto the screen completely set display+=lastline set path+=/System/Library/Frameworks/GLUT.framework/Headers/ " Don't use Ex mode, use Q for formatting map Q gq if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif if has("autocmd") au BufNewFile,BufRead *.tri set syntax=triangle au! BufRead,BufNewFile *.markdown setfiletype markdown autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:> filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! autocmd FileType text setlocal textwidth=78 autocmd BufNewFile,BufRead *.som setf st " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") if has("cscope") set csto=0 set cst " Bind C-] to cscope set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb nmap s :cs find s =expand("") nmap g :cs find g =expand("") nmap c :cs find c =expand("") nmap t :cs find t =expand("") nmap e :cs find e =expand("") nmap f :cs find f =expand("") nmap i :cs find i ^=expand("")$ nmap d :cs find d =expand("") " Using 'CTRL-spacebar' then a search type makes the vim window " split horizontally, with search result displayed in " the new window. nmap s :scs find s =expand("") nmap g :scs find g =expand("") nmap c :scs find c =expand("") nmap t :scs find t =expand("") nmap e :scs find e =expand("") nmap f :scs find f =expand("") nmap i :scs find i ^=expand("")$ nmap d :scs find d =expand("") " Hitting CTRL-space *twice* before the search type does a vertical " split instead of a horizontal one nmap s \:vert scs find s =expand("") nmap g \:vert scs find g =expand("") nmap c \:vert scs find c =expand("") nmap t \:vert scs find t =expand("") nmap e \:vert scs find e =expand("") nmap i \:vert scs find i ^=expand("")$ nmap d \:vert scs find d =expand("") endif " Thanks to http://clipboarded.blogspot.com/2007/10/vim-as-ide.html : map \* "syiw:Grep^Rs 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("") map \f "syiw:Find^Rs 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 ? (=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("")