All pastes #792399 Raw Edit

Something

public text v1 · immutable
·published 2007-11-21 10:52 UTC
rendered paste body
" This is a modified example vimrc

map gn :e ftp://amnoid.de/notes.txt<cr>

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 <C-d> :call ShowDoc(expand('<cword>'))<cr>

nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>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 <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
  nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
  nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
  nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
  nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
  nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
  nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>

  " Using 'CTRL-spacebar' then a search type makes the vim window
  " split horizontally, with search result displayed in
  " the new window.

  nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
  nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>

  " Hitting CTRL-space *twice* before the search type does a vertical
  " split instead of a horizontal one

  nmap <C-Space><C-Space>s
      \:vert scs find s <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space><C-Space>g
      \:vert scs find g <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space><C-Space>c
      \:vert scs find c <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space><C-Space>t
      \:vert scs find t <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space><C-Space>e
      \:vert scs find e <C-R>=expand("<cword>")<CR><CR>
  nmap <C-Space><C-Space>i
      \:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  nmap <C-Space><C-Space>d
      \:vert scs find d <C-R>=expand("<cword>")<CR><CR>
endif


" Thanks to http://clipboarded.blogspot.com/2007/10/vim-as-ide.html :

map \* "syiw:Grep^Rs<cr>
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>")


map \f "syiw:Find^Rs<cr>
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("<args>")