Skip to content

Instantly share code, notes, and snippets.

@emson

emson/.vimrc

Created Aug 22, 2011
Embed
What would you like to do?
My .vimrc file
" .vimrc based on Ryan Tomayco's vim file
" https://github.com/rtomayko/dotfiles/blob/rtomayko/.vimrc
" ---------------------------------------------------------------------------
" General
" ---------------------------------------------------------------------------
set nocompatible " essential
set history=1000 " lots of command line history
set modeline " make sure modeline support is enabled
" ---------------------------------------------------------------------------
" Colors / Theme
" ---------------------------------------------------------------------------
if &t_Co > 2 || has("gui_running")
if has("terminfo")
set t_Co=16
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
syntax on
set hlsearch
endif
" ---------------------------------------------------------------------------
" Highlight
" ---------------------------------------------------------------------------
highlight Comment ctermfg=DarkGrey guifg=#444444
highlight StatusLineNC ctermfg=Black ctermbg=DarkGrey cterm=bold
highlight StatusLine ctermbg=Black ctermfg=LightGrey
" ----------------------------------------------------------------------------
" Highlight Trailing Whitespace
" ----------------------------------------------------------------------------
set list listchars=trail:.,tab:>.
highlight SpecialKey ctermfg=DarkGray ctermbg=Black
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set ruler " show the cursor position all the time
set number " line numbers
set wildmenu " turn on wild menu
set wildmode=list:longest,full
set ch=2 " command line height
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set showmatch " brackets/braces that is
set mat=5 " duration to show matching brace (1/10 sec)
" set incsearch " do incremental searching
set laststatus=2 " always show the status line
" set ignorecase " ignore case when searching
" set nohlsearch " don't highlight searches
" set visualbell " stop the bell
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
set autoindent " automatic indent new lines
set smartindent " be smart about it
set nowrap " do not wrap lines
set softtabstop=2 " yep, two
set shiftwidth=2 " ..
set tabstop=4
set expandtab " expand tabs to spaces
set nosmarttab " fuck tabs
set textwidth=80 " wrap at 80 chars by default
" ---------------------------------------------------------------------------
" Open URL on current line in browser
" ---------------------------------------------------------------------------
function! Browser ()
let line0 = getline (".")
let line = matchstr (line0, "http[^ )]*")
let line = escape (line, "#?&;|%")
exec ':silent !open ' . "\"" . line . "\""
endfunction
map ,w :call Browser ()<CR> " cursor on http url then type ,w
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file
" ---------------------------------------------------------------------------
function! StripWhitespace ()
exec ':%s/ \+$//gc'
endfunction
map ,s :call StripWhitespace ()<CR> " execute with ,s then type y/n/etc
" ---------------------------------------------------------------------------
" File Types
" ---------------------------------------------------------------------------
au BufRead,BufNewFile *.rpdf set ft=ruby
au BufRead,BufNewFile *.rxls set ft=ruby
au BufRead,BufNewFile *.ru set ft=ruby
au BufRead,BufNewFile *.god set ft=ruby
au BufRead,BufNewFile *.rtxt set ft=html spell
au BufRead,BufNewFile *.sql set ft=pgsql
au BufRead,BufNewFile *.rl set ft=ragel
au BufRead,BufNewFile *.svg set ft=svg
au BufRead,BufNewFile *.haml set ft=haml
au BufRead,BufNewFile *.md set ft=mkd tw=80 ts=2 sw=2 expandtab
au BufRead,BufNewFile *.markdown set ft=mkd tw=80 ts=2 sw=2 expandtab
au BufRead,BufNewFile *.ronn set ft=mkd tw=80 ts=2 sw=2 expandtab
au Filetype gitcommit set tw=68 spell
au Filetype ruby set tw=80 ts=2
au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim
au BufNewFile,BufRead *.mustache setf mustache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment