Skip to content

Instantly share code, notes, and snippets.

@marcelbeumer
Created January 22, 2012 17:22
Show Gist options
  • Save marcelbeumer/1657749 to your computer and use it in GitHub Desktop.
Save marcelbeumer/1657749 to your computer and use it in GitHub Desktop.
vimrc
" //////////////////////////////
" # vim settings
" //////////////////////////////
set nocompatible
syntax enable
filetype plugin on
" be able to switch buffers without saving
set hidden
" no backups or swaps needed
set nobackup
set noswapfile
" undo
set undofile
set undodir=~/.vimundo
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set incsearch
set hlsearch
" ignore case when searching
set ignorecase
" ... unless when there is a uppercase in the search
set smartcase
set nonumber
set ruler
set nolist
set clipboard=unnamed
set foldmethod=indent
set foldlevel=100
set scrolloff=3
" command completion more verbose
set wildmenu
set wildmode=list:longest
" show those long lines
set cc=80
" //////////////////////////////
" # key mappings
" //////////////////////////////
" In insert mode, open omnicomplete with handy keycombi
inoremap <silent><C-O> <C-X><C-O>
" Fold on function like stuff, hence zff (http://www.noah.org/wiki/Vim#Folding)
:nnoremap zff :/^\S\+.*=\\|^\s*ns\..*=\\|^\s*ns\s*=\\|^\s*\S*.*=\s*window\.\\|^\s*class\s\\|^\s*function\s\\|^\s*def\s/<CR>:set foldexpr=getline(v:lnum)!~@/ foldlevel=0 foldcolumn=0 foldmethod=expr<CR>
" //////////////////////////////
" # leader key mappings
" //////////////////////////////
let mapleader = ","
map <Leader>t :CommandT<cr>
map <leader>, :NERDTreeToggle<cr>
map <leader>m :NERDTreeMirror<cr>
map <Leader>y :YRShow<cr>
map <Leader>n :set number!<cr>
map <leader>l :set list!<CR>
" convert newlines and retab
map <Leader>r :%s/\r/\r/g<cr>gg<cr>:retab<cr>
" removed whitespace in empty lines, and remove trailing whitespace
map <Leader>w :%s/^\s\+$//ge<cr>:%s/\(\S\)\s\+$/\1/ge<cr>
" Easy folding on search expr
map <silent><leader>z :set foldexpr=getline(v:lnum)!~@/ foldlevel=0 foldcolumn=0 foldmethod=expr<CR>
" //////////////////////////////
" filetype settings
" //////////////////////////////
autocmd BufWritePost *.coffee silent CoffeeMake! | cwindow
" //////////////////////////////
" commands
" //////////////////////////////
command ClearUndo silent !rm ~/.vimundo/*
command SudoWrite w !sudo tee % > /dev/null
command JSHint !jshint % --show-non-errors
command -range=% Xmltidy <line1>,<line2>!tidy -xml -indent -utf8 -q --indent-spaces 4
command -range=% BeautifyJS <line1>,<line2>!js-beautify -i
command -range=% UglifyJS <line1>,<line2>!uglifyjs
" //////////////////////////////
" plugin config
" //////////////////////////////
call pathogen#infect()
" let g:CommandTMaxHeight=20 " only show so many items
let g:CommandTMatchWindowReverse=1 " best match down
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:yankring_history_file = '.yankring_history'
let NERDTreeIgnore=['\.pyc$', '\~$']
let NERDTreeBookmarksFile = $HOME . '/.vim_nerdtree_bookmarks'
let NERDTreeWinSize=50
let NERDTreeShowBookmarks=1
" //////////////////////////////
" gui
" //////////////////////////////
if has('gui_running')
set guioptions-=T " no toolbar
set guioptions-=r " no right scrollbar
set guioptions-=L " no left scrollbar
set vb " no bells; as macvim does not support visual bell
" set guifont=Monaco:h12
set guifont=Inconsolata:h16
" colorscheme molokai
colorscheme twilight
end
" //////////////////////////////
" highlighting
" //////////////////////////////
highlight LineOverflow ctermbg=red ctermfg=white guibg=#592929
" highlight BadWhiteSpace ctermbg=red ctermfg=white guibg=#592929
" highlight LineProximity ctermbg=red ctermfg=white guibg=#592929
" autocmd BufWinEnter,InsertLeave * match BadWhiteSpace /\s\+$/
" autocmd InsertEnter * match BadWhiteSpace /\s\+\%#\@<!$/
autocmd BufWinEnter * let w:m3=matchadd('LineOverflow', '\%>79v.\+', -1)
" autocmd BufWinEnter * let w:m4=matchadd('LineProximity', '\%<81v.\%>75v', -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment