-
Notifications
You must be signed in to change notification settings - Fork 0
/
_vimrc
337 lines (253 loc) · 8.36 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
call pathogen#infect()
let mapleader=","
set nocompatible
set viminfo='1000,f1,:1000,/1000
set history=1000
"------ Visual Options ------
syntax on
set number
"set nowrap
set vb
set ruler
set statusline=%<%f\ %h%m%r%=%{fugitive#statusline()}\ \ %-14.(%l,%c%V%)\ %P
let g:buftabs_only_basename=1
let g:buftabs_marker_modified = "+"
" Toggle whitespace visibility with ,s
nmap <Leader>sd :set list!<CR>
set listchars=tab:▸\ ,trail:·,extends:❯,precedes:❮,nbsp:×,eol:¬
" save using ,s
inoremap <Leader>s <esc> :update<CR>
nnoremap <Leader>s :update<CR>
" map escape to kj
inoremap kj <esc>
" syntastic
let g:syntastic_jshint_exec = '/usr/local/bin/jshint'
let g:syntastic_javascript_checkers = ['jshint']
let g:syntastic_css_checkers = ['csslint']
"let g:syntastic_check_on_open = 1
let g:syntastic_error_symbol = "x"
let g:syntastic_warning_symbol = "!"
" ,L = Toggle line numbers
map <Leader>L :set invnumber<CR>
"------ Generic Behavior ------
set tabstop=4
set shiftwidth=4
set hidden
filetype indent on
filetype plugin on
set autoindent
"set expandtab
set wildignore=.svn,CVS,.git,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,node_modules/*
"allow deletion of previously entered data in insert mode
set backspace=indent,eol,start
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! %!sudo tee > /dev/null %
" F2 = Paste Toggle (in insert mode, pasting indented text behavior changes)
set pastetoggle=<F2>
" ,v = Paste
map <Leader>v "+gP
" ,c = Copy
map <Leader>c "+y
" Accidentally pressing Shift K will no longer open stupid man entry
noremap K <nop>
" Edit and Reload .vimrc files
nmap <silent> <Leader>ev :e $MYVIMRC<CR>
nmap <silent> <Leader>es :so $MYVIMRC<CR>
" When pressing ,cd switch to the directory of the open buffer
map ,cd :cd %:p:h<CR>
" Wtf is Ex Mode anyways?
nnoremap Q <nop>
"------ Text Navigation ------
" Prevent cursor from moving to beginning of line when switching buffers
set nostartofline
" Keep the cursor in place while joining lines
nnoremap J mzJ`z
" H = Home, L = End
noremap H ^
noremap L $
vnoremap L g_
"------ Window Navigation ------
" ,hljk = Move between windows
nnoremap <Leader>h <C-w>h
nnoremap <Leader>l <C-w>l
nnoremap <Leader>j <C-w>j
nnoremap <Leader>k <C-w>k
noremap <Leader>1 :buffer 1<CR>
noremap <Leader>2 :buffer 2<CR>
noremap <Leader>3 :buffer 3<CR>
noremap <Leader>4 :buffer 4<CR>
noremap <Leader>5 :buffer 5<CR>
noremap <Leader>6 :buffer 6<CR>
noremap <Leader>7 :buffer 7<CR>
noremap <Leader>8 :buffer 8<CR>
noremap <Leader>9 :buffer 9<CR>
"------ Buffer Navigation ------
" Ctrl Left/h & Right/l cycle between buffers
noremap <silent> <C-left> :bprev<CR>
noremap <silent> <C-h> :bprev<CR>
noremap <silent> <C-right> :bnext<CR>
noremap <silent> <C-l> :bnext<CR>
"resize window of current buffer
nnoremap <C-RIGHT> :vertical resize +2<CR>
nnoremap <C-LEFT> :vertical resize -2<CR>
nnoremap <C-DOWN> :resize -2<CR>
nnoremap <C-UP> :resize +2<CR>
" ,q Closes the current buffer
nnoremap <silent> <Leader>q :Bclose<CR>
" ,Q Closes the current window
nnoremap <silent> <Leader>Q <C-w>c
"------ Searching ------
set incsearch
set ignorecase
set smartcase
set hlsearch
" vimgrep
nnoremap <F3> :noautocmd vimgrep /<C-R><C-W>/gj **/*.php <CR>
nnoremap <F5> :vimgrep /<C-R><C-W>/gj **/*.js <CR>
" Clear search highlights when pressing ,b
nnoremap <silent> <leader>b :nohlsearch<CR>
" http://www.vim.org/scripts/script.php?script_id=2572
" ,a will open a prmompt for a term to search for
noremap <leader>a :Ack
" ,A will close the new window created for that ack search
noremap <leader>A <C-w>j<C-w>c<C-w>l
let g:ackprg="ack -H --nocolor --nogroup --column --type-add php=.tpl"
" When searching for words with * and navigating with N/n, keep line centered vertically
"nnoremap n nzz
"nnoremap N Nzz
"nnoremap * *zz
"nnoremap # #zz
"nnoremap g* g*zz
"nnoremap g# g#zz
" CtrlP will load from the CWD, makes it easier with all these nested repos
let g:ctrlp_working_path_mode = ''
"type S, then type what you're looking for, a /, and what to replace it with
nmap S :%s//g<LEFT><LEFT>
vmap S :s//g<LEFT><LEFT>
"------ NERDTree Options ------
let NERDTreeIgnore=['CVS','\.dSYM$']
"setting root dir in NT also sets VIM's cd
let NERDTreeChDirMode=2
" Toggle visibility using ,n
noremap <silent> <Leader>n :NERDTreeToggle<CR>
" These prevent accidentally loading files while focused on NERDTree
autocmd FileType nerdtree noremap <buffer> <c-left> <nop>
autocmd FileType nerdtree noremap <buffer> <c-h> <nop>
autocmd FileType nerdtree noremap <buffer> <c-right> <nop>
autocmd FileType nerdtree noremap <buffer> <c-l> <nop>
" Open NERDTree if we're executing vim without specifying a file to open
autocmd vimenter * if !argc() | NERDTree | endif
" Close if only NERDTree open
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Hides "Press ? for help"
let NERDTreeMinimalUI=1
"------ Tagbar Plugin Options ------
" http://adamyoung.net/Exuberant-Ctags-OS-X
" http://www.vim.org/scripts/script.php?script_id=273
let g:tagbar_width=26
noremap <silent> <Leader>y :TagbarToggle<CR>
" ,ct = Builds ctags
"map <Leader>ct :! /usr/local/bin/ctags -R *<CR>
"------ Fugitive Plugin Options ------
"https://github.com/tpope/vim-fugitive
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gr :Gremove<CR>
nnoremap <Leader>gl :Glog<CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gm :Gmove
nnoremap <Leader>gp :Ggrep
nnoremap <Leader>gR :Gread<CR>
nnoremap <Leader>gg :Git
nnoremap <Leader>gd :Gdiff<CR>
"------ Text Editing Utilities ------
" ,T = Delete all Trailing space in file
map <Leader>T :%s/\s\+$//<CR>
" ,U = Deletes Unwanted empty lines
map <Leader>U :g/^$/d<CR>
" ,R = Converts tabs to spaces in document
map <Leader>R :retab<CR>
" Deletes trailing space in file upon write
" autocmd BufWritePre * :%s/\s\+$//e
"------ JSON Filetype Settings ------
au BufRead,BufNewFile *.json set filetype=json
let g:vim_json_syntax_conceal = 0
nmap <silent> =j :%!python -m json.tool<CR>:setfiletype json<CR>
"------ CoffeeScript Filetype Settings ------
au BufNewFile,BufReadPost *.coffee set shiftwidth=2 softtabstop=2 expandtab
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
au BufWritePost *.coffee silent make!
autocmd QuickFixCmdPost * nested cwindow | redraw!
"------ PHP Filetype Settings ------
" ,p = Runs PHP lint checker on current file
map <Leader>p :! php -l %<CR>
" ,P = Runs PHP and executes the current file
map <Leader>P :! php -q %<CR>
au FileType php set omnifunc=phpcomplete#CompletePHP
set tags=tags;/
"------ GUI Options ------
if has("gui_running")
" Hides toolbar and scrollbars and File menu
set guioptions=egt
" Highlights the current line background
set cursorline
colorscheme Tomorrow-Night
"autocmd VimEnter * TagbarOpen
"Invisible character colors
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59
if has("gui_macvim") " OS X
"set guifont=Monaco:h14
set guifont=Monaco:h12
"set noantialias
"set transparency=15
" Swipe to move between bufers :D
map <silent> <SwipeLeft> :bprev<CR>
map <silent> <SwipeRight> :bnext<CR>
" Cmd+Shift+N = new buffer
map <silent> <D-N> :enew<CR>
" Cmd+t = new tab
nnoremap <silent> <D-t> :tabnew<CR>
" Cmd+w = close tab (this should happen by default)
nnoremap <silent> <D-w> :tabclose<CR>
" Cmd+1...9 = go to that tab
map <silent> <D-1> 1gt
map <silent> <D-2> 2gt
map <silent> <D-3> 3gt
map <silent> <D-4> 4gt
map <silent> <D-5> 5gt
map <silent> <D-6> 6gt
map <silent> <D-7> 7gt
map <silent> <D-8> 8gt
map <silent> <D-9> 9gt
" OS X probably has ctags in a weird place
let g:tagbar_ctags_bin='/usr/local/bin/ctags'
elseif has("gui_gtk2") " Linux
set guifont=monospace\ 9
" Alt+n = new buffer
map <silent> <A-n> :enew<CR>
" Alt+t = new tab
nnoremap <silent> <A-t> :tabnew<CR>
" Alt+w = close tab
nnoremap <silent> <A-w> :tabclose<CR>
" Alt+1...9 = go to that tab
map <silent> <A-1> 1gt
map <silent> <A-2> 2gt
map <silent> <A-3> 3gt
map <silent> <A-4> 4gt
map <silent> <A-5> 5gt
map <silent> <A-6> 6gt
map <silent> <A-7> 7gt
map <silent> <A-8> 8gt
map <silent> <A-9> 9gt
elseif has("gui_win32") " Windows
" WHAT ARE YOU DOING WITH YOUR LIFE?!
endif
else
set t_Co=256
"colorscheme Mustang
set mouse=a
endif
"------ Local Overrides ------
if filereadable($HOME.'/.vimrc_local')
source $HOME/.vimrc_local
endif