forked from doenietzomoeilijk/vimstuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot-vimrc
More file actions
432 lines (365 loc) · 12.1 KB
/
dot-vimrc
File metadata and controls
432 lines (365 loc) · 12.1 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
429
430
431
" Run Pathogen
call pathogen#infect()
" Set leader to comma
let mapleader = ","
" Generic settings
set encoding=utf-8
set mouse=a
" Indenting stuff
set tabstop=2
set shiftwidth=2
set nosmartindent " As smartindent conflicts with filetype
set nocindent
set smarttab
set smartcase
set nowrap " We just CODE to the correct width, bitches!
set whichwrap+=<,>,h,l
set linebreak
set showbreak=~\ \ \
set backspace=indent,eol,start
" UI, mostly
set number " We'll default to this. <Leader>nn switches to relativenumber
set ruler
set cmdheight=3
set showcmd
set showmode
set scrolloff=2
set novisualbell
set noerrorbells
set nohidden
set equalalways
" Status line
set laststatus=2
" Split stuff
set noequalalways " Don't resize splits when closing windows
set splitright
" set splitbelow
" For browser weenies
nnoremap <space>
nnoremap <S-space>
" Folding
set foldmethod=indent
set foldlevel=100
" Highlighting search
set showmatch
set matchpairs+=<:>
set hlsearch
noremap <leader>h :let @/ = ""<CR> " clear search pattern to disable hlsearch
map <leader>n :noh<CR> " Turn off hlsearch until the next search
" Syntax stuff
filetype plugin indent on
syntax enable
map <leader>s :syntax enable<CR>
map <leader>hi :so $VIMRUNTIME/syntax/hitest.vim<CR>
" PURDY COLORZ
let g:CSApprox_verbose_level = 0
set bg=dark
colorscheme anotherdark
" colorscheme molokai
"colorscheme mustang
"colorscheme wombat256
" map <silent><F2> :PREVCOLOR<cr>
" map <silent><F3> :NEXTCOLOR<cr>
if has("gui_running")
set guioptions-=T
set guioptions-=r
set guitablabel=%M%t
set cursorline
hi SpecialKey guifg=#444444
hi NonText guifg=#444444 guibg=bg
hi Todo gui=undercurl
endif
if exists("&colorcolumn")
set colorcolumn=80
hi ColorColumn ctermbg=234 guibg=#232526
else
" Hightlight the end of long lines (>120 chars)
" http://blog.ezyang.com/2010/03/vim-textwidth/
" augroup vimrc_autocmds
" autocmd BufRead * match OverLength /\%120v.*/
" autocmd BufRead * highlight OverLength none
" map <Leader>l :highlight OverLength ctermbg=darkgrey guibg=#592929<CR>
" map <Leader>L :highlight OverLength none<CR>
" augroup END
endif
" Netrw stuff
let g:netrw_liststyle=1
" let g:netrw_browse_split = 4
let g:netrw_silent = 1
let g:netrw_list_hide='\.pyc,^\..*'
let g:netrw_sort_sequence='[\/]$,TODO$,INSTALLATION$,README$,\<core\%(\.\d\+\)\=\>,^\.,\.h$,\.c$,\.cpp$,\.php$,\.py$,\.html$,*,\.o$,\.obj$,\.txt$,\.info$,\.swp$,\.bak$,\.pyc$,\~$,\.[dmg|xcf|jpg|png]$'
let g:explHideFiles='^\.,.*\.pyc$,.svn'
let g:netrw_alto = 1 " open o-splits at the bottom
let g:netrw_altv = 1 " open v-splits to the right
" let g:netrw_winsize = 35
" let g:netrw_preview = 1
if has('gui_macvim')
behave xterm
set selectmode=
set keymodel=
set mousemodel=popup_setpos
" set noantialias
set gfn=Inconsolata-dz:h12
set gfn=EnvyCodeR:h13
" set gfn=Monaco:h10
" set antialias
" set gfn=Consolas:h12
" set transp=2
let macvim_skip_cmd_opt_movement = 1
let macvim_hig_shift_movement = 1
let g:netrw_browsex_viewer='open'
map <S-D-[> :tabprevious<CR>
map <S-D-]> :tabnext<CR>
set linespace=4
set fuoptions=maxvert,maxhorz,background:Normal " Fullscreen options
let g:netrw_ctags='/opt/local/bin/ctags'
let Tlist_Ctags_Cmd='/opt/local/bin/ctags'
else
let g:netrw_ctags='/usr/bin/ctags'
let Tlist_Ctags_Cmd='/usr/bin/ctags'
endif
set textwidth=80
set formatoptions=lcqn " see :help fo-table for letter meaning
" Directories that have // at the end will be expanded to the full file path
" See: http://stackoverflow.com/questions/4331776/change-vim-swap-backup-undo-file-name/4331812#4331812
" Move temporary files to ~/.vimtmp/ instead of current dir
if ! isdirectory(expand('~/.vimtmp'))
call mkdir(expand('~/.vimtmp'))
endif
if isdirectory(expand('~/.vimtmp'))
set directory=~/.vimtmp//
else
set directory=.,/var/tmp//,/tmp//
endif
" Save tons of history and undo (Thanks, Arnout)
set history=1000
set undolevels=1000
" Set persistent undo, only works on >73
if exists("&undodir") && exists("&undofile")
" Setup persistently store the undo folder
if ! isdirectory(expand('~/.vimundo'))
call mkdir(expand('~/.vimundo'))
endif
set undodir=~/.vimundo
set undofile
endif
" Lets :GLVS actually install stuff
let g:GetLatestVimScripts_allowautoinstall=1
autocmd BufRead,BufNewFile *.smarty set ft=smarty.html.javascript
autocmd BufRead,BufNewFile,BufEnter *.json set ft=javascript
autocmd BufRead,BufNewFile,BufEnter *.ejs set ft=javascript
autocmd BufRead,BufNewFile,BufEnter *.md set ft=markdown
autocmd BufRead,BufEnter */hotelmodules-*/*.class set ft=php
autocmd FileType html set ft=html.javascript.css.php
autocmd FileType markdown set formatoptions+=t
autocmd FileType javascript set expandtab
autocmd FileType perl set expandtab tabstop=4 shiftwidth=4 shiftround
autocmd BufRead,BufNewFile,BufEnter *.tt2 set ft=tt2html
autocmd BufRead,BufNewFile,BufEnter */frags/**.html set ft=tt2
" Seems to cause errors in console vim.
" autocmd FileType javascript setlocal expandtab
" From http://github.com/devjj/vim-config/blob/master/.vimrc After editing, run
autocmd! bufwritepost .vimrc source ~/.vimrc
map <leader>vv :tabe ~/.vimrc<CR>
map <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" I like my own php snippets better
" call ResetSnippets('php')
" call ExtractSnipsFile('~/.vim/my_snips/php.snippets', 'php')
" SnippetsEmu stuff
" function! ReloadSnippets( snippets_dir, ft )
" if strlen( a:ft ) == 0
" let filetype = "_"
" else
" let filetype = a:ft
" endif
" call ResetSnippets()
" call GetSnippets( a:snippets_dir, filetype )
" endfunction
" nmap <leader>rr :call ReloadSnippets(snippets_dir, &filetype)<CR>
let g:snippets_dir="~/.vim/my_snips/"
let g:snips_author="Max Roeleveld"
" autocmd bufwritepost snippet :call ReloadSnippets(snippets_dir, &filetype)<CR>
" Allow me to switch between number and relativenumber
function! SwitchNumbering()
if exists("&relativenumber")
if &number && ! &relativenumber
set relativenumber
elseif ! &number && &relativenumber
set number
endif
else
echo "Your VIM doesn't support relativenumber!"
endif
endfunction
nmap <leader>nn :call SwitchNumbering()<CR>
" Add a status line by default
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
" set laststatus=2
" Session saving
" set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
" set sessionoptions=resize,winsize
" Invisible characters *********************************************************
set listchars=trail:·,tab:‣‒,eol:¬,extends:«,precedes:»
set nolist
noremap <leader>i :set list!<CR> " Toggle invisible chars"
map <leader>cd :cd %:p:h<CR>
nnoremap <leader>c :set cursorline!<CR>
nnoremap <leader>C :set cursorcolumn!<CR>
" http://www.sontek.net/Python-with-a-modular-IDE-(Vim)
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.pyc,.pyo
set tags+=tags;/
set tags+=$HOME/.vim/tags/python.ctags
" TagList
map <leader>t :TlistToggle<CR>
let Tlist_Sort_Type = "order"
let Tlist_Use_SingleClick = 1
let Tlist_Show_Menu = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Enable_Fold_Column = 1
let Tlist_Close_On_Select = 0
let Tlist_Use_Right_Window = 0
let Tlist_Process_File_Always=1
let Tlist_Show_One_File=1
let Tlist_Display_Prototype=1
let Tlist_Max_Submenu_Items=50
let Tlist_Max_Tag_Length=30
map <silent><A-Right> :bnext!<CR>
map <silent><A-Left> :bprevious!<CR>
" MiniBufExplorer -- currently not used
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplModSelTarget = 1
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapCTabSwitchBufs = 1
" Stop the beeping AND flashing
set vb t_vb=".
" Re-select text you just pasted so you can indent it and stuff
nnoremap <leader>q gqip
" Cycling between buffers
map <c-tab> :bn<cr>
map <s-c-tab> :bp<cr>
" Quick jumping between splits
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <S-C-H> :bp<CR>
map <S-C-L> :bn<CR>
" vmap ' c'<c-r>"'<esc>
" vmap " c"<c-r>""<esc>
" vmap ( c(<c-r>")<esc>
" Remap num island to proper numbers
:inoremap <Esc>Oq 1
:inoremap <Esc>Or 2
:inoremap <Esc>Os 3
:inoremap <Esc>Ot 4
:inoremap <Esc>Ou 5
:inoremap <Esc>Ov 6
:inoremap <Esc>Ow 7
:inoremap <Esc>Ox 8
:inoremap <Esc>Oy 9
:inoremap <Esc>Op 0
:inoremap <Esc>On .
:inoremap <Esc>OQ /
:inoremap <Esc>OR *
:inoremap <Esc>Ol +
:inoremap <Esc>OS -
" If I want help, I'll ask for it (instead of inadvertly hit my F1 when I
" actually wanted ESC)
nmap <F1> <Esc>
inoremap jj <Esc>
inoremap JJ <Esc>
" Hey, F5 wasn't used yet. Let's map :make to that!
map <F5> :make<cr>
" Search for diff separater stuff
nnoremap <Leader>fd /^<<<<<<<\\|^=======\\|^>>>>>>><CR>
" NERDCommenter stuff
let g:NERDRemoveExtraSpaces=1
let g:NERDSpaceDelims=1
let g:NERDComInsertMap='<c-c>'
let g:NERDCustomDelimiters = { 'html': { 'left': '<!--', 'right': '-->'}}
" WinManager
map <c-w><c-b> :BottomExplorerWindow<cr>
map <c-w><c-f> :FirstExplorerWindow<cr>
map <c-w><c-t> :WMToggle<cr>
let g:winManagerWidth=40
let g:winManagerWindowLayout = "FileExplorer,TagList|BufExplorer"
" Disable auto-php-folding if PIV is plugged in
let g:DisableAutoPHPFolding=1
" Favourites for file-explorer
let g:favDirs='/Volumes/max.hotels.local/git/hotelveiling/'."\n"
" SVN stuff
command! Svnadd execute "!svn add %" | execute "!svn propset svn:keywords Id %"
" Stolen from http://www.reddit.com/r/vim/comments/gexi6/a_smarter_statusline_code_in_comments/
hi StatColor guibg=#95e454 guifg=black ctermbg=lightgreen ctermfg=black
hi Modified guibg=orange guifg=black ctermbg=lightred ctermfg=black
function! MyStatusLine(mode)
let statusline=""
if a:mode == 'Enter'
let statusline.="%#StatColor#"
endif
let statusline.="\(%n\)\ %f\ "
if a:mode == 'Enter'
let statusline.="%*"
endif
let statusline.="%#Modified#%m"
if a:mode == 'Leave'
let statusline.="%*%r"
elseif a:mode == 'Enter'
let statusline.="%r%*"
endif
if exists("*Tlist_Get_Tagname_By_Line")
let statusline .= "\ [%{Tlist_Get_Tagname_By_Line()}]" " file type
endif
" let statusline .= "%{fugitive#statusline()}"
let statusline .= "\ (%l/%L,\ %c)\ %P%=%h%w\ %y\ [%{&encoding}:%{&fileformat}]\ \ "
return statusline
endfunction
au WinEnter * setlocal statusline=%!MyStatusLine('Enter')
au WinLeave * setlocal statusline=%!MyStatusLine('Leave')
set statusline=%!MyStatusLine('Enter')
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi StatColor guibg=orange ctermbg=lightred
elseif a:mode == 'r'
hi StatColor guibg=#e454ba ctermbg=magenta
elseif a:mode == 'v'
hi StatColor guibg=#e454ba ctermbg=magenta
else
hi StatColor guibg=red ctermbg=red
endif
endfunction
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi StatColor guibg=#95e454 guifg=black ctermbg=lightgreen ctermfg=black
vmap <Leader>,, :s/, \@!\(.\+\)/, \1/g<CR>
function! FixLeCode()
" Vervang in PHP =/==/===/=> zonder spaties eromheen door versie MET spaties.
:%s/\(!\|+\|-\|\.\|=\|<\|>\)\@<!\(=\|==\|===\|=>\|+=\|-=\)\( \|>\|=\)\@!/ \2 /g
:g/function/s/ = /=/g
" Zet verdomme spaties achter je komma's:
" @TODO moet nog een beetje getweaked worden voor binnen explode() etc
" :v/\(explode\|implode\)/s/, \@!/, /g
" Geen spaties aan het einde van regels
:%s/\s\+$//g
" Wat nou, braces op de volgende regel
:g/^\s*\(\(public\|private\) \)\?function .\+)$/j
endfunction
" Keep some space between if/for/foreach/while and the paren'd part, also keep
" some space between the closing paren and the opening brace
function! FixSpaceBrace()
:%s/\(if\|elseif\|for\|foreach\|while\)(/\1 (/g
:%s/){/) {/g
:%s/function \(\w\+\) (/function \1(/g
endfunction
function! DeEscapeCodify()
" Removes escape codes, at least from Javascript
:%s/\\x1b\[\(\d\+;\)*\d\+m//g
endfunction
" Remove whitespace from code files on save
function! StripTrailingWhite()
let l:winview = winsaveview()
silent! %s/\s\+$//
call winrestview(l:winview)
endfunction
autocmd BufWritePre *.{php,py,pl,js} call StripTrailingWhite()