Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
143 lines (112 sloc) 3.99 KB
" load in bundles
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
" leader
let mapleader = ","
" Make backspace key delete when in insert mode
set backspace=2
" Use Vim settings, rather then Vi settings
set nocompatible
" No tmp files
set nobackup
set nowritebackup
set noswapfile
" enable syntax highlighting
syntax on
colorscheme solarized
set background=dark
" Highlight last search term
set hlsearch
" softtabs 2 spaces
set tabstop=2
set shiftwidth=2
set expandtab
" List chars
set list " Show invisible characters
set listchars="" " Reset the listchars
set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "."
set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the last column when wrap is
" off and the line continues beyond the left of the screen
" don't wrap lines
set nowrap
" Smart tab completion that will that will either insert
" a tab character or autocomplete
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
return "\<c-p>"
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
" display relative line numbers
set relativenumber
set number
" NERDTree configuration
let NERDTreeShowLineNumbers=1
let NERDTreeWinSize = 50
" mappings
map <Leader>n :NERDTreeToggle<CR>
" Edit file in directory of current buffer
nmap <leader>ew :e <C-R>=expand('%:h').'/'<cr>
nmap <leader>es :sp <C-R>=expand('%:h').'/'<cr>
nmap <leader>ev :vsp <C-R>=expand('%:h').'/'<cr>
nmap <leader>et :tabe <C-R>=expand('%:h').'/'<cr>
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
" Use The Silver Searcher
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 ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
" Automatically reload vimrc when it changes
augroup reload_vimrc
autocmd BufWritePost .vimrc,vimrc source $MYVIMRC
augroup END
augroup vimrcEx
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.jst set filetype=html
" Enable spellchecking for Markdown
autocmd FileType markdown setlocal spell
" Automatically wrap at 80 characters for Markdown
autocmd BufRead,BufNewFile *.md setlocal textwidth=80
augroup END
" Tell vim-rspec to run in tmux session
let g:rspec_command = 'call Send_to_Tmux("bundle exec spring rspec {spec}\n")'
" Default CtrlP to use regexp mode
let g:ctrlp_regexp = 1
" vim-rspec mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" window navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>