""""""""""""""""""""""""""""""""""" " The vimrc file of Evan Morikawa " """"""""""""""""""""""""""""""""""" """"""""""""""""""" " Vundle Packages " """"""""""""""""""" " Simply type :BundleInstall to install everything. set nocompatible " Does not use old vi quirks filetype off " Required temporarily for vundle set rtp+=~/.vim/bundle/vundle call vundle#rc() " Helps me collaborate " """""""""""""""""""""""" " A Git wrapper so awesome, it should be illegal Bundle 'tpope/vim-fugitive' " Helps me see " """""""""""""""" " Colors CSS tags with the appropriate color. Bundle 'skammer/vim-css-color' " Add CSS3 syntax support to vim's built-in `syntax/css.vim` Bundle 'hail2u/vim-css3-syntax' " HAML, SASS, SCSS support for Vim Bundle 'tpope/vim-haml' " Less syntax support Bundle 'groenewege/vim-less' " CoffeeScript support for vim Bundle 'kchmck/vim-coffee-script' " Markdown syntax for vim Bundle 'tpope/vim-markdown' " Shows indent level Bundle 'nathanaelkane/vim-indent-guides' " Solarized color schemes. We use Evan's color scheme for dark and " Solarized for light bg. Bundle 'altercation/vim-colors-solarized' " Live Markdown preview " https://github.com/suan/vim-instant-markdown " Bundle 'suan/vim-instant-markdown' " A Vim plugin which shows a git diff in the gutter (sign column) " Bundle 'airblade/vim-gitgutter' " Helps me search " """"""""""""""""""" Bundle 'grep.vim' " Helps me move " """"""""""""""""" " A tree explorer plugin for vim " Bundle 'scrooloose/nerdtree' " Ruby on Rails power tools Bundle 'tpope/vim-rails' " Extends % operator to match html tags and others. Bundle 'tsaleh/vim-matchit' " Peepopen quickly finds and open files Bundle 'topfunky/PeepOpen-EditorSupport', {'rtp': 'vim-peepopen/'} " Unload/delete/wipe a buffer, keep its window(s) Bundle 'bufkill.vim' " Helps me type " """"""""""""""""" " Quoting/parenthesizing made simple " cs " ds " vS Bundle 'tpope/vim-surround' " Enable repeating supported plugin maps with '.' Bundle 'tpope/vim-repeat' " A parser for a condensed HTML format " after a block of sparkup-formatted pre-html Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} " Easily comment in and out lines " __ Bundle 'tomtom/tcomment_vim' " Vim motions on speed. Replaces the in " Bundle 'Lokaltog/vim-easymotion' " Helps me execute " """""""""""""""""""" " Awesome autocomplete " http://valloric.github.io/YouCompleteMe/ if has("gui_macvim") Bundle 'Valloric/YouCompleteMe' end " Write snippets in vim. " after a snippet key " Bundle 'msanders/snipmate.vim' Bundle 'SirVer/ultisnips' " Key remappings ordered by approximate frequency of use" """"""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = "," "Quick escape and saving via button-mashing inoremap jk inoremap kj cnoremap jk cnoremap kj inoremap df :w inoremap fd :w noremap df :w noremap fd :w "Easier movement around the page noremap 3 noremap 3 noremap 3j noremap 3k noremap 5l noremap 5h noremap noremap noremap 0 noremap $ noremap j gj noremap k gk noremap 0 ^ "Move between buffers noremap h noremap l " Peep open to search between files if has("gui_macvim") " macmenu &File.New\ Tab key= map PeepOpen end "Change to light bg noremap l :set background=light:colorscheme solarized "Change to dark bg noremap d :set background=dark:colorscheme evan """"" AWESOME SEARCHING "In visual mode when you press * or # to search for the current selection vnoremap * :call VisualSearch('f') vnoremap # :call VisualSearch('b') " Search and highlight what's under the cursor. Also automatically copies " the word to both yank and the mac paste buffer thanks to " clipboard=unnamed noremap *ye " Search via grep what's under the cursor. noremap *ye:Gr " " Unhighlight noremap :nohl " Space bar searching noremap / noremap "Git commands noremap gs :Gstatus noremap ga :Gwrite noremap gc :Gcommit -a noremap gd :Gdiff noremap gl :Gdiff HEAD~1 noremap gb :Gbrowse "Reselect visual block after indent/outdent vnoremap < >gv " Edit Vimrc " $MYVIMRC points to the ~/.vimrc file nnoremap ev :e $MYVIMRC " Re-source vimrc nnoremap sv :source $MYVIMRC " Puts current file name in the mac paste buffer. Useful for operating on " the file from the command line. noremap :CopyTitle " noremap :bd:vsp:bn:buffers noremap :bd "Info about the character undernath cursor nnoremap gi ga " Toggles paste mode and shows value of the option nnoremap :set invpaste paste? noremap :%s/ "Smart folding on shift-space nnoremap zz @=(foldlevel('.')?'za':'l') vnoremap zz zf "shell shortcuts in command mode cnoremap cnoremap cnoremap cnoremap cnoremap "Sparkup to create HTML let g:sparkupExecuteMapping = '' "Displays the tag type under the cursor. Really useful for generating colors map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans <' \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" " Remove the Windows ^M - when the encodings gets messed up noremap m mmHmt:%s///ge'tzt'm " Settings " """""""""""" filetype plugin indent on " Turn on filetype after Vundle is setup colorscheme evan syntax enable set nu "Turn on line numbers set lbr "Wordwrapping doesn't break words in the middle set wrap "wrap lines set list "All characters print. Including meta characters set ts=2 set sw=2 set ruler "Shows the ruler set magic "set magic on, for regular expressions set mat=2 "two-tenths of a second blink set smarttab set wildmenu "Enhanced tab completion set autoread "Set to auto read when a file is changed from the outside set vb t_vb= "disables visual bell set hlsearch set showmode " Says whether or not paste mode is turned on or off set t_Co=256 "Enable colored terminal let &t_Co=256 set incsearch "Incremental search set smartcase "Will switch to case sensitive if a cap is used set showmatch "Shows matches on search set expandtab "Replaces tabs with spaces set tabstop=2 "Num characters when tab is pushed set ignorecase "case insensitive search but see next option set autoindent "Enable automatic alignment during insertions set noswapfile "Don't use swp files set smartindent "Tries to recognize code and indent set cmdheight=2 "The commandbar height set shiftwidth=2 set textwidth=74 " Maximum line length at 74 characters. Trigged with gq set noerrorbells set novisualbell set history=1000 set laststatus=2 "Always show the status line set restorescreen set encoding=utf8 set shell=/bin/sh "Use bash shell set guioptions-=T "Removes GUI bars set guioptions-=l "Removes scrollbars set guioptions-=r "Removes scrollbars set guioptions-=b "Removes scrollbars set colorcolumn=75 "Have a line of at 75 characters wide. The max width is 74 characters set pastetoggle= " Binds F2 to pastetoggling set clipboard=unnamed " All yank commands now go to mac clipboard set wildmode=list:longest,full " bash command line tab completion set listchars=tab:\|\ ,trail:●,extends:>,precedes:<,nbsp:+ "Whitespace showing set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P " set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c " Custom commands " """"""""""""""""""" " Removes all trailing whitespace command! Whitespace %s/\s\+$//e command! -nargs=1 Gr Grep -ErinI --exclude-dir=log --exclude-dir=tmp --exclude-dir=coverage * command! CopyTitle !echo "%\c" | pbcopy " Autocommands " """"""""""""""" " Mixes in html filetype to web languages augroup html_mixin autocmd! au BufRead,BufNewFile *.php set ft=php.html au BufRead,BufNewFile *.erb set ft=eruby.html au BufRead,BufNewFile *.coffee set ft=coffee augroup END " Utility Methods " """""""""""""""""" match LineTooLong /\%>74v.\+/ function! CurDir() let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") return curdir endfunction function! HasPaste() if &paste return 'PASTE MODE ' else return '' endif endfunction function! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Foo endfunction function! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_reg endfunction """""""""""""""""""""""""""""" " Language Specific Settings " """""""""""""""""""""""""""""" " Python " """""""""" augroup python_helpers autocmd! au FileType python setl \ tabstop=4 \ softtabstop=4 \ shiftwidth=4 \ textwidth=80 au BufWrite *.py :call DeleteTrailingWS() "Deletes trailing whitepace let python_highlight_all = 1 au FileType python syn keyword pythonDecorator True None False self au BufNewFile,BufRead *.jinja set syntax=htmljinja au BufNewFile,BufRead *.mako set ft=mako au BufNewFile,BufRead *.less set ft=less augroup END let &t_Sf="\[3%dm" let &t_Sb="\[4%dm" let &t_te="\[?47l" let &t_ti="\[?47h" " Rabl " """""""" augroup rabl_helpers autocmd! au BufRead,BufNewFile *.rabl setf ruby au BufRead,BufNewFile *.rabl syn keyword rubyRabl node attribute object child collection attributes glue extends au BufRead,BufNewFile *.rabl hi def link rubyRabl Function augroup END """"""""""" " PLUGINS " """"""""""" " Nerd Tree " """"""""""""" " noremap :NERDTreeToggle " Sparkup " """"""""""" let sparkupNextMapping = '' " Vim Indent Guides " """"""""""""""""""""" let g:indent_guides_auto_colors = 0 augroup indent_guides autocmd! au BufRead,BufNewFile * IndentGuidesEnable augroup END " YouCompleteMe and UltiSnips " """"""""""""""""""""" " https://github.com/Valloric/YouCompleteMe/issues/36 function! g:UltiSnips_Complete() call UltiSnips_ExpandSnippet() if g:ulti_expand_res == 0 if pumvisible() return "\" else call UltiSnips_JumpForwards() if g:ulti_jump_forwards_res == 0 return "\" endif endif endif return "" endfunction au BufRead,BufNewFile,BufEnter * exec "inoremap " . g:UltiSnipsExpandTrigger . " =g:UltiSnips_Complete()" let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger=""