-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
399 lines (301 loc) · 8.88 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
" General Settings
" {{{
" Don't care about vi
set nocompatible
" Security
set modelines=0
" load all bundles
runtime bundle/pathogen/autoload/pathogen.vim
let g:pathogen_disabled = []
" FuzzyFinder/L9 requires Vim 7.2 and floating-point support
if v:version < '702' || !has('float')
call add(g:pathogen_disabled, 'l9')
call add(g:pathogen_disabled, 'fuzzyfinder')
endif
" Gundo requires Vim 7.3 and Python
if v:version < '703' || !has('python')
call add(g:pathogen_disabled, 'gundo')
endif
" Pathogen loads bundles
call pathogen#infect()
" file handling
set binary
set noendofline
set nobackup
set backupdir=~/.vim/tmp
set autowrite
set encoding=utf-8
set modeline
set modelines=2
set undofile
set undodir=~/.vim/tmp
set directory=~/.vim/tmp
set shortmess+=A
" interface
set hidden
set lazyredraw
set splitbelow
set splitright
set scrolloff=5
set virtualedit+=block
set nostartofline
" command prompt and status line
set showcmd
set shell=/bin/bash
set ruler
set laststatus=2
set history=1000
set report=0
set wildmenu
set wildmode=longest:full,full
set wildignore=*.pyc,*.o,*.lo,*.la,*.swp,*.db,*.bak,*.dat,*.,tmp,*.mdb,*~,~*
" searching
"nnoremap / /\v
"vnoremap / /\v
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
nnoremap <tab> %
vnoremap <tab> %
" }}}
" Display Settings
" {{{
" Syntax
syntax on
" Indent automatically
filetype plugin indent on
set autoindent
set smartindent
set cindent
" Set font
set gfn=Mensch-Powerline\ 10
set antialias
" color scheme
set t_Co=256
colorscheme mymustang
" Turn off bells
set noerrorbells
set novisualbell
" statusline
autocmd VimEnter,BufRead,BufNewFile * highlight StatusLineGray cterm=bold ctermfg=231 ctermbg=241 gui=bold guifg=white guibg=#666666
autocmd VimEnter,BufRead,BufNewFile * highlight StatusLineRed cterm=bold ctermfg=231 ctermbg=88 gui=bold guifg=white guibg=#913d3b
autocmd VimEnter,BufRead,BufNewFile * highlight StatusLineGreen cterm=bold ctermfg=231 ctermbg=28 gui=bold guifg=white guibg=#368736
set statusline=
set stl+=%#StatusLineGray#\ %n\ %* " buffer number
set stl+=%#StatusLineGreen#%{fugitive#statusline()[4:-2]}%* " Git status
set stl+=%#StatusLineRed#%r%* " read-only flag
set stl+=%#StatusLineRed#%m%* " modified flag
set stl+=\ %<\"%f\"\ " file name
set stl+=%y " file type
set stl+=[%{strlen(&fenc)?&fenc:&enc} " file encoding
set stl+=%{&bomb?',BOM':''} " BOM flag
set stl+=%{&ff!='unix'?','.toupper(&ff):''}]\ " file format
set stl+=%= " left/right separator
set stl+=%-20.(%l/%L,%c%)\ %P " cursor position
" line numbers
set numberwidth=4
"set relativenumber
" Always show line numbers, but only in current window.
set number
":au WinEnter * :setlocal number
":au WinLeave * :setlocal nonumber
" Automatically resize vertical splits.
:au WinEnter * :set winfixheight
:au WinEnter * :wincmd =
" cursor line
"autocmd BufEnter,WinEnter * if bufname('%') != '-MiniBufExplorer-' && &buftype != 'quickfix' | setlocal cursorline | endif
"autocmd WinLeave * setlocal nocursorline nocursorcolumn
" highlight trailing whitespace
autocmd VimEnter,BufRead,BufNewFile * highlight Whitespace ctermbg=236 guibg=#333333
autocmd VimEnter,BufRead,BufNewFile * match Whitespace /\s\+$/
" }}}
" Text Formatting
" {{{
" Handle text wrapping
set wrap
set textwidth=79
set formatoptions=qrn1
" Set recommended limit to 85
set colorcolumn=85
set selection=inclusive
set backspace=indent,eol,start
set whichwrap+=<,>,[,],h,l
" indents
filetype plugin indent on
set autoindent
set smartindent
set nocindent
" avoid auto-indenting pound signs
inoremap # x<C-H>#
" tabs
set noexpandtab
set smarttab
set shiftround
" completion
inoremap <C-Tab> <C-X><C-O>
" diffing
set diffopt+=iwhite
" Case insensitive search
set ic
" Higlhight search
set hls
" Wrap text instead of being on one line
set lbr
" Adjust Tabs
set listchars=tab:▸\ ,conceal:?,eol:\
set list
" Adjust Tab Size
set tabstop=4
set ts=4
set shiftwidth=4
set softtabstop=4
" Copy/paste to system (if available)
set clipboard=unnamed
if has('unnamedplus')
set clipboard=unnamedplus
endif
" }}}
" Custom Filetype Settings
" {{{
filetype plugin on
" FileType autocommands
augroup ftype
au!
" Set vim folding
au FileType vim set foldmethod=marker
" Change column limit for HTML (exception)
au FileType html set colorcolumn=120
" PHP Autocomplete
au FileType php set omnifunc=phpcomplete#CompletePHP
augroup END
" PHP Generated Code Highlights (HTML & SQL)
let php_sql_query=1
let php_htmlInStrings=1
let php_baselib = 1
let php_special_functions = 1
let php_alt_comparisons = 1
let php_alt_AssignByReference = 1
" }}}
" Abbreviations
" {{{
iabbrev twcopy TurnWheel Designs (cc) 2011
iabbrev phpcom /*<cr>Coded by Steven Bower<cr>TurnWheel Designs (cc) 2011<cr><cr>/<cr>
" FileType abbreviations
augroup ftype_abbrev
au!
au FileType php,javascript :iabbrev <buffer> iff if () {}<left><left><left><left>
au FileType php :iabbrev <buffer> func function() {}<left><left><left><left><left>
au FileType python :iabbrev <buffer> iff if:<left>
augroup END
" }}}
" Keybindings
" {{{
" Manage parens
onoremap p i(
onoremap ip :<c-u>normal! f(vi(<cr>
" Change leader key
let mapleader=","
" Remove current line, and past it below following line
nnoremap - ddp
" Move line up instead of down
nnoremap _ ddkP
" Delete current line in insert mode
inoremap <c-d> <esc>ddi
" Shortcut to :
nnoremap ; :
" map Ctrl+C to Escape
inoremap <c-c> <esc>
" move to matching pair with Tab in visual mode
vmap <Tab> %
" Replace selected with yank buffer, without storing current
vmap r "_dP
" scroll in insert mode
inoremap <C-e> <C-o><C-e>
inoremap <C-y> <C-o><C-y>
" ,/ remove highlighted search
nnoremap <silent> <leader>/ :noh<CR>
" ," - Add quotes around selected word
nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel
" ,^ - Move up one line
nnoremap <leader>^ d$k$a<cr><esc>p>>
" ,1-9 - quick buffer switching
nnoremap <silent> <leader>1 :b1<CR>
nnoremap <silent> <leader>2 :b2<CR>
nnoremap <silent> <leader>3 :b3<CR>
nnoremap <silent> <leader>4 :b4<CR>
nnoremap <silent> <leader>5 :b5<CR>
nnoremap <silent> <leader>6 :b6<CR>
nnoremap <silent> <leader>7 :b7<CR>
nnoremap <silent> <leader>8 :b8<CR>
nnoremap <silent> <leader>9 :b9<CR>
" ,n - new tab
nnoremap <silent> <leader>n :tabnew<cr>
" ,r - reload current buffer
nnoremap <silent> <leader>r :edit<cr>
" ,R - reload vimrc
nnoremap <silent> <leader>R :runtime! ~/.vimrc<cr>:nohlsearch<cr>
" ,v - Reselect pasted text
nnoremap <silent> <leader>v V`]
" ,s - split vertically
nnoremap <silent> <leader>s :vsplit<cr>
" ,w - write file
nnoremap <silent> <leader>w :write<cr>
" Removes whitespace
nnoremap <silent> ,W :%s/\s\s*$//e<CR>:nohlsearch<CR>:echo "Trailing whitespace cleared"<CR>:echohl none<CR>
" ,+ - Continuous Column Scrolling
nnoremap <silent> <leader>+ :<c-u>let @z=&so<cr>:set so=0 noscb<cr>:bo vs<cr>Ljzt:setl scb<cr><c-w>p:setl scb<cr>:let &so=@z<cr>
" ,; - Add ; to end of current line
nnoremap <silent> <leader>; :<c-u>normal! mqA;<esc>`q
" ,F - Fix all
nmap <silent> <leader>F :Ftab<CR>:Fchar<CR>,W
" ,m - Fix wrapped paragraph (Use with caution)
nnoremap <silent> <leader>m gqk<CR><leader>W
" ,z
autocmd FileType html :nnoremap <buffer> <leader>z :normal gg=G<CR>
" MacOSX Shortcuts
" CMD+1-0 jumps to tab 1-10, Shift+CMD+1-0 jumps to tab 11-20:
let s:windowmapnr = 0
let s:wins='1234567890!@#$%^&*()'
while (s:windowmapnr < strlen(s:wins))
exe 'noremap <silent> <D-' . s:wins[s:windowmapnr] . '> ' . (s:windowmapnr + 1) . 'gt'
exe 'inoremap <silent> <D-' . s:wins[s:windowmapnr] . '> <C-O>' . (s:windowmapnr + 1) . 'gt'
exe 'cnoremap <silent> <D-' . s:wins[s:windowmapnr] . '> <C-C>' . (s:windowmapnr + 1) . 'gt'
exe 'vnoremap <silent> <D-' . s:wins[s:windowmapnr] . '> <C-C>' . (s:windowmapnr + 1) . 'gt'
let s:windowmapnr += 1
endwhile
unlet s:windowmapnr s:wins
" }}}
" Commands
" {{{
" :W Custom Websync Script (git.turnwheel.com:websync)
command! Wsave w! | cd %:p:h | ! websync %
" :Rmchar removes ^M characters (line endings)
command! Fchar :%s///g
" :Fixtab re-tabs buffers with current tab settings
" Change noet to et to expandtabs
command! Ftab :set noet|retab!
command! Fquote :%s/=\([^"][^> ]\{0,80\}\)/="\1"/gc
" :w!! - write as sudo (don't have to re-open file!)
ca w!! w !sudo tee >/dev/null "%"
" }}}
" Plugin Settings
" {{{
" Nerd Tree
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDChristmasTree=1
" ,d - toggle NERDTree
nnoremap <silent> <leader>d :NERDTreeToggle %:p:h<CR>
" ,t - toggle tagbar
nnoremap <silent> <leader>t :TagbarToggle<CR>
" ,u - open gundo
nnoremap <silent> <leader>u :GundoToggle<CR>
" ,a - Ack
nnoremap <leader>a :Ack
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
let g:Powerline_symbols = 'fancy'
" }}}