Skip to content

Instantly share code, notes, and snippets.

@birkirb
Created June 2, 2009 02:28
Show Gist options
  • Save birkirb/121943 to your computer and use it in GitHub Desktop.
Save birkirb/121943 to your computer and use it in GitHub Desktop.
My .vimrc
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
set nocompatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules according to the
" detected filetype. Per default Debian Vim only load filetype specific
" plugins.
if has("autocmd")
filetype indent on
endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set ruler " show the cursor position all the time
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes) in terminals
" Source a global configuration file if available
" XXX Deprecated, please move your changes here in /etc/vim/vimrc
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"set expandtab
"set smarttab
"set softtabstop=2
"set shiftwidth=2
set backspace=2
set list listchars=trail:.
highlight SpecialKey ctermfg=DarkGray
set list listchars=tab:\|_,trail:.
"set fileformats=unix
map <silent> <C-N> :bnext <Return>
map <silent> <C-P> :bprevious <Return>
map <silent> <C-C> :bdelete <Return>
filetype plugin indent on " Enable filetype-specific indenting and plugins
" Load matchit (% to bounce from do to end, etc.)
runtime! macros/matchit.vim
augroup myfiletypes
" Clear old autocmds in group
autocmd!
" autoindent with two spaces, always expand tabs
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
augroup END
" Delete trailing white space from rb and rhtml files
"autocmd BufWritePre *.* :%s/$//e
autocmd BufWritePre *.rb :%s/\s\+$//e
autocmd BufWritePre *.rhtml :%s/\s\+$//e
autocmd BufWritePre *.rjs :%s/\s\+$//e
autocmd BufWritePre *.feature :%s/\s\+$//e
" Always yank to the clipboard
set clipboard=unnamed
"set clipboard+=autoselect
set go+=a
" Colorscheme
"colorscheme wombat
" Add Rack config file as Ruby type
au BufNewFile,BufRead *.ru set filetype=ruby
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./", "", "")
execute ":e ".l:line
endfunction
command! -nargs=1 Find :call Find("<args>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment