-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
280 lines (206 loc) · 5.79 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
"++++++++++++++++++
"++ Essentials ++++
"++++++++++++++++++
"Terminal and VIM compatibility
set nocompatible
set t_Co=256
"Syntax highlighting
syntax on
syntax enable
filetype plugin indent on
"Disables Syntastic for HTML files. Too many edge cases
let syntastic_mode_map = { 'passive_filetypes': ['html'] }
"Who doesn't want line numbers?
set number
"Spell checking
"zg to add to dictionary
"z= for suggestions
"set spell spelllang=en_us
"Ctrl+P
set runtimepath^=~/.vim/bundle/ctrlp.vim
" Syntastic settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"++++++++++++++++++++
"++ Load plugins ++++
"++++++++++++++++++++
"Pathogen (https://github.com/tpope/vim-pathogen)
call pathogen#infect()
"++++++++++++++++
"++ Mappings ++++
"++++++++++++++++
"Default explorer will behave more like NERDTree
let g:netrw_liststyle=3 " Use tree-mode as default view
" jj can be type faster than <Esc>
imap jj <Esc>
map <leader>o :MRU<CR>
"Easy window moves
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
"Easy 'big' moves
map J 10j
map K 10k
map L 10l
map H 10h
"Window switching: ctrl+[hjkl]
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
nnoremap <C-Q> <C-W>q
"Sick tab
map = gt
map - gT
"Move around more like a normal editor
nnoremap j gj
nnoremap k gk
".vimrc auto source
nnoremap <Leader>sv :so $MYVIMRC<CR>
"shortcut to edit .vimrc and .bash_profile
noremap <Leader>v :tabe ~/.vimrc<CR>
noremap <Leader>V :tabe ~/.bashrc<CR>
"<Ctrl+b> + buffer number or name fragment to jump to it
map <C-b> :ls<cr>:b<space>
"Tight interaction between vim and tmux
map <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vl :VimuxRunLastCommand<CR>
"Bundle Exec Rspec <current file>
map <Leader>ber :call VimuxRunCommand("clear; bundle exec rspec " . bufname("%"))<CR>
"++++++++++++++
"++ Visual ++++
"++++++++++++++
"Solarized color scheme (https://github.com/altercation/vim-colors-solarized)
let g:solarized_termcolors=256
let g:solarized_visibility = "high" "Could be low, normal or high
let g:solarized_contrast = "high"
set background=dark
colorscheme solarized
"colorscheme slate
" This shows what you are typing as a command. Awesome.
set showcmd
"Highlight lines if they're over 80 chars. New way. (VIM > 7.2)
if exists('+colorcolumn')
highlight ColorColumn ctermbg=8
set colorcolumn=80
endif
"Highlight lines if they're over 80 chars. Old way.
"highlight OverLength ctermbg=red ctermfg=white guibg=#592929
"match OverLength /\%81v.\+/
"Show the cursor position all the time
set ruler
"Show title in title bar
set title
"Highlight the current line
set cursorline
" Makes the current line stand out with bold and in the numberline
hi CursorLine cterm=bold
"display invisible chars
set list
set listchars=tab:⇥·,trail:·
"Trailing spaces in red
match Error /\v\s+$/
" Show (partial) command in status line.
set showcmd
"++++++++++++
"++ Code ++++
"++++++++++++
" This being the 21st century, I use Unicode
set encoding=utf-8
set fileencoding=utf-8
" Show matching brackets.
set showmatch
" always set autoindenting on
set ai
" Don't wrap words by default
set textwidth=0
"Filetype adjustments
autocmd BufEnter *.md setlocal filetype=markdown
autocmd BufEnter *.css.tmpl setlocal filetype=css
autocmd BufEnter *.js.tmpl setlocal filetype=javascript
autocmd BufEnter *.html.eco setlocal filetype=html
"++++++++++++++
"++ Search ++++
"++++++++++++++
" Case insensitive matching
set ignorecase
" Case sensitive matching if caps in search string
set smartcase
" Search on steroids
set hlsearch
set incsearch
" Use BASH style completion
set wildmenu
set wildmode=list:longest,full
" Set grep to be git grep
set grepprg=git\ grep\ -n
" The <Left>s are here to place the cursor where the patterns needs to go
noremap <leader>g :grep! <cword>\| copen<Left><Left><Left><Left><Left><Left><Left>
"++++++++++++++++++++
"++ Indentation! ++++
"++++++++++++++++++++
set expandtab
set softtabstop=4
set tabstop=4
set shiftwidth=4
"+++++++++++++
"++ Misc. ++++
"+++++++++++++
"MRU awesomeness
let MRU_Max_Entries = 1000
"Keep 10,000 lines of command line history. You cannot have enough.
set history=10000
"Save the Marks. All of them.
set viminfo='1000,f1
"Default split opening position shall be to the right and below
set splitright
set splitbelow
"Auto-reload files, if there's no conflict
set autoread
"Do not keep buffer after tab closed
set nohidden
"no intro message, no swap-file message
set shortmess+=IA
" leave more context around cursor
set scrolloff=3
set whichwrap=b,s,h,l,<,>,[,]
set backspace=indent,eol,start
"Code folding. za
"set foldmethod=indent
"set foldlevel=99
"Manual folds, backed up and restored
set foldmethod=manual
"Hopefully ctags
"Easy debugging
ab pdb import pdb; pdb.set_trace()
ab pry require 'pry'; binding.pry
"Python & most languages
set softtabstop=4
set tabstop=4
set shiftwidth=4
"For frontend stuff the convention is 2 spaces
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType js setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Ruby/Java are also 2 spaces
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType java setlocal shiftwidth=2 tabstop=2 softtabstop=2
"Go indentation (tabs)
autocmd FileType go set expandtab!
"Stop caring about compiled crap
set wildignore+=*.o,*.obj
"Ignore VCS internals
set wildignore+=.git,.hg
"Python projects
set wildignore+=*.pyc,*templates/*.py,#*#,build/*
"JavaScript projects
set wildignore+=node_modules/*
"Ruby project
set wildignore+=tmp