forked from thoughtbot/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
151 lines (123 loc) · 3.6 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
let mapleader = ","
set backspace=2
set history=50
set lazyredraw
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
set nobackup
set nocompatible " Use Vim settings, rather then Vi settings
set noswapfile
set nowritebackup
set nowrap
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set clipboard+=unnamed " pasting
set ttimeoutlen=25
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000
set winwidth=80
set tabstop=2
set shiftwidth=2
set expandtab
syntax on
filetype plugin indent on
" Display extra whitespace
set list listchars=tab:»·,trail:·
" Use Ack instead of Grep when available
if executable("ag")
set grepprg=ag\ --nogroup\ --nocolor
endif
" Open all grep commands into quicklist
autocmd QuickFixCmdPost *grep* cwindow
" Color scheme
set background=dark
hi NonText guibg=#060606
hi Folded guibg=#0A0A0A guifg=#9090D0
hi LineNr term=bold ctermfg=DarkGrey guifg=DarkGrey
" " Numbers
set relativenumber
set numberwidth=5
" Bubble single lines
nmap <C-Down> ]e
nmap <C-Up> [e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Buffers
map <Leader>b :buffers<CR>:buffer<space>
map <Leader>gs :Gstatus<CR>
map <Leader>gac :Gcommit -m -a ""<LEFT>
map <Leader>gc :Gcommit -m ""<LEFT>
map <Leader>m :Rmodel
map <Leader>sm :RSmodel
map <Leader>su :RSunittest
map <Leader>sv :RSview
map <Leader>vc :RVcontroller<cr>
map <Leader>vf :RVfunctional<cr>
map <Leader>vi :tabe ~/.vimrc<CR>
map <Leader>vm :RVmodel<cr>
map <Leader>vu :RVunittest<CR>
map <Leader>vv :RVview<cr>
" File Operations
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
" Snippets are activated by Shift+Tab
let g:snippetsEmu_key = "<S-Tab>"
" Tab completion options
set wildmode=list:longest,list:full
set complete=.,w,t
" Indent if we're at the beginning of a line. Else, do completion.
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<C-p>"
endif
endfunction
inoremap <tab> <C-r>=InsertTabWrapper()<CR>
inoremap <s-tab> <C-n>
" Tags
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
" Remove trailing whitespace
autocmd BufWritePre * :%s/\s\+$//e
" Cucumber navigation commands
autocmd User Rails Rnavcommand step features/step_definitions -glob=**/* -suffix=_steps.rb
autocmd User Rails Rnavcommand config config -glob=**/* -suffix=.rb -default=routes
" Get off my lawn
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" vim-rspec mappings
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>s :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" Improve syntax highlighting
au BufRead,BufNewFile Gemfile set filetype=ruby
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.md setlocal spell
au BufRead,BufNewFile *.md setlocal textwidth=80
" Open new split panes to right and bottom
set splitbelow
set splitright
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" configure syntastic syntax checking to check on open and save
let g:syntastic_check_on_open=1
let g:syntastic_ruby_exec='ruby-1.9.3-p194'
" configure nerdtree
map <F2> :NERDTreeToggle<CR>
" configure ctrlp
let g:ctrlp_show_hidden = 1
set wildignore+=*/tmp/*,*/log/*,.DS_Store
" Local config
if filereadable("~/.vimrc.local")
source ~/.vimrc.local
endif