Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
428 lines (301 loc) · 14.6 KB
/
Copy pathvimrc
File metadata and controls
428 lines (301 loc) · 14.6 KB
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
" Tom's VIM Config
" tom@takeontom.com
" https://github.com/takeontom/tom-vim
set encoding=utf-8
" ------------------------------------------------------------------------------
" Vundle Auto Install
" ------------------------------------------------------------------------------
set nocompatible " be iMproved
filetype off " required!
" Auto install Vundle. Credit:
" http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" ------------------------------------------------------------------------------
" Vundle
" ------------------------------------------------------------------------------
Plugin 'gmarik/vundle'
" ------------------------------------------------------------------------------
" Tomorrow Night Theme
" ------------------------------------------------------------------------------
Plugin 'chriskempson/tomorrow-theme', {'rtp': 'vim'}
:silent! colorscheme Tomorrow-Night-Bright
set background=dark " using a dark background
set t_Co=256
" ------------------------------------------------------------------------------
" Supertab
" ------------------------------------------------------------------------------
Plugin 'ervandew/supertab'
" ------------------------------------------------------------------------------
" Ack
" ------------------------------------------------------------------------------
Plugin 'mileszs/ack.vim.git'
let g:ack_default_options = " -s -H --nocolor --nogroup --column --smart-case --follow"
" ------------------------------------------------------------------------------
" Syntastic
" ------------------------------------------------------------------------------
Plugin 'scrooloose/syntastic'
let g:syntastic_check_on_open=1
let g:syntastic_enable_highlighting=1
let g:syntastic_auto_loc_list=1
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['less'] }
" ------------------------------------------------------------------------------
" Fugitive (git plugin)
" ------------------------------------------------------------------------------
Plugin 'tpope/vim-fugitive'
nmap <Leader>gs :Gstatus<CR>
nmap <Leader>gb :Gblame<CR>
nmap <Leader>gh :Gbrowse<CR>
nmap <Leader>gd :Gdiff<CR>
nmap <Leader>gf :Gvsplit<CR>
" ------------------------------------------------------------------------------
" Surround
" ------------------------------------------------------------------------------
Plugin 'tpope/vim-surround.git'
" ------------------------------------------------------------------------------
" ctrlp
" ------------------------------------------------------------------------------
Plugin 'kien/ctrlp.vim'
nmap <Leader>t :CtrlP<CR>
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_use_caching = 1
let g:ctrlp_working_path_mode = ''
let g:ctrlp_match_window = 'bottom,order:ttb,min:1,max:30,results:30'
let g:ctrlp_max_files = 1000000
let g:ctrlp_max_depth = 200
let g:ctrlp_switch_buffer = 'et'
" ------------------------------------------------------------------------------
" CommandT
" ------------------------------------------------------------------------------
" Plugin 'wincent/Command-T'
"
" " Don't really want any limit to the number of files CommandT shows...
" let g:CommandTMaxFiles=999999
"
" " Flush the CommandT buffer when saving new files
" let g:isNewFile = 0
" function! SetIsNewFile()
" if ! filereadable(expand("<afile>:p"))
" let g:isNewFile = 1
" else
" let g:isNewFile = 0
" endif
" endfunction
" function! FlushCommandTOnNewFileSave()
" if g:isNewFile == 1
" CommandTFlush
" endif
" endfunction
" autocmd BufWritePre * call SetIsNewFile()
" autocmd BufWritePost * call FlushCommandTOnNewFileSave()
"
" ------------------------------------------------------------------------------
" vim-misc
" ------------------------------------------------------------------------------
Plugin 'xolox/vim-misc.git'
" ------------------------------------------------------------------------------
" Powerline
" ------------------------------------------------------------------------------
Plugin 'Lokaltog/powerline'
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
" ------------------------------------------------------------------------------
" EasyTags
" ------------------------------------------------------------------------------
Plugin 'xolox/vim-easytags.git'
set updatetime=4000 " l9 tries to set this to 10ms!
" ------------------------------------------------------------------------------
" auto_mkdir
" ------------------------------------------------------------------------------
Plugin 'auto_mkdir'
" ------------------------------------------------------------------------------
" l9
" ------------------------------------------------------------------------------
Plugin 'L9'
" ------------------------------------------------------------------------------
" FuzzyFinder
" ------------------------------------------------------------------------------
Plugin 'FuzzyFinder'
nmap <Leader>ft :FufTag<CR>
nmap <Leader>ff :FufFile<CR>
nmap <Leader>fb :FufBuffer<CR>
" ------------------------------------------------------------------------------
" Tagbar
" ------------------------------------------------------------------------------
Plugin 'majutsushi/tagbar'
" Toggle the tagbar window
nnoremap <silent> <F8> :TagbarToggle<CR>
" ------------------------------------------------------------------------------
" Markdown
" ------------------------------------------------------------------------------
Plugin 'tpope/vim-markdown'
" ------------------------------------------------------------------------------
" Django template highlighting
" ------------------------------------------------------------------------------
Plugin 'django.vim'
" ------------------------------------------------------------------------------
" Vim CSS3 syntax
" ------------------------------------------------------------------------------
Plugin 'hail2u/vim-css3-syntax'
" ------------------------------------------------------------------------------
" Vim-Less
" ------------------------------------------------------------------------------
Plugin 'groenewege/vim-less'
" ------------------------------------------------------------------------------
" Install Vundle Bundles if 1st load
" ------------------------------------------------------------------------------
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
filetype plugin indent on " required!
" ------------------------------------------------------------------------------
" Basic Settings
" ------------------------------------------------------------------------------
set nocompatible " Use vim features - ignore vi compatibility
" ------------------------------------------------------------------------------
" File Handling
" ------------------------------------------------------------------------------
set autoread " reads the file if it changes in background
set backup " make backup files
set backupdir=/tmp " where to put backup files
set directory=/tmp " directory to place swap files in
" ------------------------------------------------------------------------------
" Basic Preferences
" ------------------------------------------------------------------------------
set noerrorbells " don't make noise
set showcmd " show the command being typed
" ------------------------------------------------------------------------------
" Visuals
" ------------------------------------------------------------------------------
set cursorline " highlight current line
"set cursorcolumn " highlight current column
" ------------------------------------------------------------------------------
" Status Line
" ------------------------------------------------------------------------------
if exists('g:loaded_fugitive')
set statusline=%< " truncate from start
set statusline+=%f " file path
set statusline+=\ %h " help buffer flag
set statusline+=%m " modified flag
set statusline+=%r " readonly flag
set statusline+=\ %{fugitive#statusline()} " fugutive git branch, etc.
set statusline+=%= " start right
set statusline+=%-14.(%l,%c%V%) " line, column, virtual column number
set statusline+=\ %P " percentage through file
endif
" ------------------------------------------------------------------------------
" Searching
" ------------------------------------------------------------------------------
set incsearch " highlight search matches when typing search
set laststatus=2 " always show the status line
set ignorecase " case insensitive by default
set infercase " case inferred by default
set smartcase " if there are caps, go case-sensitive
" ------------------------------------------------------------------------------
" Editing
" ------------------------------------------------------------------------------
set showmatch " show matching brackets
set matchtime=2 " how many tenths of a second to blink matching brackets for
set list " we do what to show tabs, to ensure we get them out of my files
set listchars=tab:>-,trail:~ " show tabs and trailing
set nonumber " turn on line numbers
set numberwidth=4 " We are good up to 99999 lines
set scrolloff=3 " Give 3 lines of context when at bottom of window
set nowrap " do not wrap line
set nofoldenable " really hate code-folding...
set splitright " vertical split to the right
set splitbelow " horizontal split to the right
" ------------------------------------------------------------------------------
" Formatting
" ------------------------------------------------------------------------------
set formatoptions=tcorq " See help:fo-table
set expandtab " no real tabs please!
set smartindent " do smart autoindenting when starting a new line
set shiftround " when at 3 spaces, and I hit > ... go to 4, not 7
set shiftwidth=4 " auto-indent amount when using cindent, >>, << and stuff like that
set softtabstop=4 " when hitting tab or backspace, how many spaces
" should a tab be (see expandtab)
set tabstop=4 " real tabs should be 8, and they will show with set list on
set textwidth=0 " disable auto-wrapping by default. allow filetypes to overide
set autoindent
syntax on
" ------------------------------------------------------------------------------
" GUI
" ------------------------------------------------------------------------------
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=R "remove right-hand scroll bar
set guioptions-=l "remove left-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
set guioptions-=b "remove bottom scroll bar
set guioptions-=B "remove bottom scroll bar
set guioptions-=e "remove tab list
set guioptions-=c "use console prompts instead of silly popups
set mouse-=a " disable mouse integration
set guifont=Monospace\ 9
" ------------------------------------------------------------------------------
" Command Mode
" ------------------------------------------------------------------------------
set wildmode=longest,list " At command line, complete longest common string, then list alternatives.
set history=999
" ------------------------------------------------------------------------------
" Plugin Loading
" ------------------------------------------------------------------------------
filetype plugin on
" ------------------------------------------------------------------------------
" OmniCompletion
" ------------------------------------------------------------------------------
set ofu=syntaxcomplete#Complete " use default omni completion. override per ft.
if has("gui_running")
" C-Space seems to work under gVim on both Linux and win32
inoremap <C-Space> <c-x><c-o>
else " no gui
if has("unix")
inoremap <Nul> <c-x><c-o>
else
" I have no idea of the name of Ctrl-Space elsewhere
endif
endif
" ------------------------------------------------------------------------------
" Tags
" ------------------------------------------------------------------------------
" search for tags in the current directory, then work up if no match found
set tags=./tags;/
" open tag in vertical split, centre on line
map <leader>] :vsp <CR>:exec("tag ".expand("<cword>"))<CR>zz
" ------------------------------------------------------------------------------
" File Type Autocmds
" ------------------------------------------------------------------------------
if !exists("autocommands_loaded")
let autocommands_loaded = 1
autocmd! BufNewFile,BufRead *.dhtml setlocal ft=htmldjango
autocmd! BufNewFile,BufRead *.pde setlocal ft=arduino
autocmd! BufNewFile,BufRead Berksfile setlocal ft=ruby
autocmd! BufNewFile,BufRead Cheffile setlocal ft=ruby
autocmd! BufNewFile,BufRead Vagrantfile setlocal ft=ruby
autocmd! BufNewFile,BufRead *.md setlocal fo+=at|setlocal tw=80|setlocal wrap
endif
" ------------------------------------------------------------------------------
" Handy Utils
" ------------------------------------------------------------------------------
" remembers where you were the last time you edited the file, and returns to the same position.
"au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" Fix bad whitespace
function! FixBadWhiteSpace()
retab
%s/\s*$//
''
:endfunction