Skip to content

Instantly share code, notes, and snippets.

@alandotcom
Created April 24, 2014 03:10
Show Gist options
  • Select an option

  • Save alandotcom/11240176 to your computer and use it in GitHub Desktop.

Select an option

Save alandotcom/11240176 to your computer and use it in GitHub Desktop.
.vimrc
set nocompatible " choose no compatibility with legacy vi
set synmaxcol=120 " limit syntax highlighting to first 120 col
set number " line numbers
set colorcolumn=80
"" Set cursor lines in current window
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
"" Recognize Markdown files
au BufRead,BufNewFile *.md set syntax=markdown
"" QuickFix window after any grep
autocmd QuickFixCmdPost *grep* cwindow
"" Autocomplete options
set complete=.,b,u,]
set wildmode=longest,list:longest
set completeopt+=menu,preview
let mapleader = ","
"" Paste mode toggle: F2
nnoremap <Leader>c :set invpaste paste?<CR>
set pastetoggle=<Leader>c
set showmode
" Don't show undo files in the explorer
let g:netrw_list_hide='\.un\~$,\.orig$'
"" Pathogen
execute pathogen#infect()
"" Toggle line numbers
nnoremap <F3> :NumbersToggle<CR>
nnoremap <F4> :NumbersOnOff<CR>
"" Load VIM Sensible Defaults Automatically
"" Wrapping and Indenting
set nowrap " don't wrap lines
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
set linebreak " Wrap lines at convenient points
set smartindent
"" :Wrap command to turn on wrapping mapped to ,w
command! -nargs=* Wrap set wrap! nolist! wrap?
nnoremap <Leader>w :Wrap<CR>
" Make wrapped lines easier to read
let &showbreak=repeat(' ', 14)
" Rspec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>r :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" Tslime
let g:rspec_command = 'call Send_to_Tmux("zeus rspec {spec}\n")'
vmap <C-c><C-c> <Plug>SendSelectionToTmux
nmap <C-c><C-c> <Plug>NormalModeSendToTmux
nmap <C-c>r <Plug>SetTmuxVars
"" Turn on the mouse
if has('mouse')
set mouse=a
endif
"" Highlight whitespace
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
"" Highlighting Fenced Blocks in Markdown
let g:markdown_github_languages = ['ruby', 'erb=eruby', 'javascript']
"" Folding
set foldmethod=indent "fold based on indent
set foldnestmax=3 "deepest fold is 3 levels
set nofoldenable "dont fold by default
"" Scrolling
set scrolloff=8 "Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
"" Turn off swap files
set noswapfile
set nobackup
set nowb
"" Persistent Undo
" Keep undo history across sessions, by storing in file.
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
"" ,ls to switch buffers
:nnoremap <Leader>ls :buffers<CR>:buffer<Space>
"" Ctrl+P
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_custom_ignore = '\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py'
let g:ctrlp_working_path_mode = 0
let g:ctrlp_dotfiles = 0
let g:ctrlp_switch_buffer = 0
nnoremap <Leader>p :CtrlPTag<CR>
" The Silver Searcher
" http://robots.thoughtbot.com/faster-grepping-in-vim
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_use_caching = 0
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
else
set grepprg=git\ grep\ --no-color
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_use_caching = 0
" bind K to grep word under cursor
nnoremap K :Ggrep <C-R>=expand("<cword>")<CR><CR>
endif
" bind ,s to grep shortcut
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
" command! -nargs=+ GGgrep execute 'silent Ggrep! <args>' | copen 15
nnoremap <Leader>s :Ag<SPACE>
"" Solarized Dark
set background=dark
colorscheme solarized
"" Remove trailing whitespace
:nnoremap <silent> <F6> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
"" Mappings for Tab alignment
:vmap <Leader>a= :Tabularize /=<CR>
:nmap <Leader>a: :Tabularize /:\zs<CR>
:vmap <Leader>a: :Tabularize /:\zs<CR>
:nmap <Leader>a> :Tabularize /=><CR>
:vmap <Leader>a> :Tabularize /=><CR>
:nmap <Leader>a{ :Tabularize /{<CR>
:vmap <Leader>a{ :Tabularize /{<CR>
"" Vim Airline Settings
let g:airline_powerline_fonts = 1
"" Rainbow parens
autocmd Syntax clojure RainbowParenthesesLoadRound
autocmd BufEnter *.clj RainbowParenthesesToggle
autocmd BufLeave *.clj RainbowParenthesesToggle
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
"" Goyo (Distraction Free)
map <Leader>z :Goyo<CR>
let g:goyo_width = 80
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment