view .vimrc @ 307:e37b00236907

zshrc: work around my shell function that turns on utf8 in screen The zsh built in which was getting confused by the function, and always claimed screen was installed. I'm finally running into machines with tmux but not screen, so I noticed.
author Augie Fackler <raf@durin42.com>
date Sat, 19 Jan 2013 19:29:58 -0600
parents 2233cb266ab0
children
line wrap: on
line source

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1
endif

"set number             " Show line number
set nocompatible	" Use Vim defaults (much better!)
set bs=2		" allow backspacing over everything in insert mode
set autoindent
"set nosmartindent
"set backup		" keep a backup file
set viminfo='20,\"50	" read/write a .viminfo file, don't store more
			" than 50 lines of registers
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set hidden " allow background buffers that aren't written out
set wildmode=list:longest,full " be more like my shell


set ignorecase " unsure
set smartcase

set scrolloff=3 " keep 3 lines of context

set incsearch " search as you type

" buffer switching/management, might as well use those keys for something
" useful
"map <Right> :bnext<CR>
"imap <Right> <ESC>:bnext<CR>
"map <Left> :bprev<CR>
"imap <Left> <ESC>:bprev<CR>
"map <Del> :bd<CR>

filetype plugin indent on
colorscheme gothic


" Only do this part when compiled with support for autocommands
if has("autocmd")
    " python settings
    autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
    autocmd FileType python set tabstop=4|set softtabstop=4|set shiftwidth=4|set expandtab
    autocmd FileType python setlocal noautoindent nosmartindent
    "autocmd BufRead,BufNewFile *melange*/** call confirm(string([&filetype, expand('<amatch>')]))
    autocmd BufRead,BufNewFile *melange*/*.py setlocal sw=2 ts=2

    " In text files, always limit the width of text to 78 characters
    autocmd BufRead *.txt set tw=78
    " When editing a file, always jump to the last cursor position
    autocmd BufReadPost * if line("'\"") > 0 && line ("'\"") <= line("$") | exe "normal g'\"" | endif
endif

if has("cscope")
    set csprg=/usr/bin/cscope
    set csto=0
    set cst
    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
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
    syntax on
    set hlsearch
endif

" Highlight trailing whitespace
"au Syntax * syn match Error /\s\+$/ | syn match Error /^\s* \t\s*/
" strip trailing whitespace on save
autocmd FileType c,cpp,java,php,python autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))

" Highlight past column 80
:highlight Over80ColLimit term=inverse,bold cterm=bold ctermbg=red ctermfg=white gui=bold guibg=red guifg=white
:syntax match Over80ColLimit /\%81v.*/

if &term=="xterm"
    set t_Co=8
    set t_Sb=[4%dm
    set t_Sf=[3%dm
endif

function! Find(name)
  let l:_name = substitute(a:name, "\\s", "*", "g")
  let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.pyc\" -and -not -name \"*.o\" -and -not -name \"*.i\" -and -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./", "", "")
  execute ":e ".l:line
endfunction
command! -nargs=1 Find :call Find("<args>")