-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
618 lines (513 loc) · 18.5 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
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
" ****************
" Strider's vimrc
" ****************
"
" 2010-2014 Mathieu Comandon, WTFPL License (http://sam.zoy.org/wtfpl/)
"
" More vimrcs
" ------------
"
" gmarik
" https://github.com/gmarik/vimfiles/blob/master/vimrc
"
" mitechie
" https://github.com/mitechie/pyvim
"
" matsko
" https://github.com/matsko/.vimrc/blob/master/.vimrc
"
" nvie
" http://github.com/nvie/vimrc/blob/master/vimrc
"
" Funcion keys
" ------------
"
" F1: Help
" F2: Close buffer
" F3: Toggle NERDTree
" F4: Available
" F5: Previous buffer
" F6: Next buffer
" F7: Toggle paste mode
" F8: Run Linter (Flake8, CoffeeLint, …)
" F9: Toggle semantic highlighting
" F10: Run file (currently supported: python, bash, html)
" F11: Reserved for fullscreen switching by WM or Terminal emulator
" F12: Available
" Shortcuts
" ---------
"
" <Control>f Search for occurences of a string using :Ag
" <Leader>/ Remove search highlight
" <Leader>l Toggle invisible characters
" <Leader>c copy to system clipboard
" <Leader>v paste from system clipboard
" <Leader>e edit vimrc
" <Leader>E reload vim configuration
" <Leader>f format the current file with ALEFix
" <Leader>tr Wrap selection in Django 'trans' templatetag
" <Leader>% Wrap selection in generic {% %} templatetag
" <Leader>{ Wrap selection in generic {{ }} templatetag
" <Leader>' Transform a 2-column text line to a dict like syntax
" <Leader>ad Transform function arguments to dict syntax
" <Leader>da Transform dict syntax to function argument syntax
" :w!! save file with sudo
"
call plug#begin('~/.vim/plugged')
Plug 'alvan/vim-closetag'
Plug 'chazy/cscope_maps'
Plug 'Valloric/MatchTagAlways'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
" Syntax plugins
Plug 'sheerun/vim-polyglot'
let g:polyglot_disabled = ['javascript']
" Lenguage support
Plug 'othree/html5.vim' " HTML 5
Plug 'nvie/vim-flake8' " Python
Plug 'larsbs/vim-xmll' " XML
Plug 'jelera/vim-javascript-syntax' " JavaScript
Plug 'pangloss/vim-javascript' " JavaScript
Plug 'marijnh/tern_for_vim' " JavaScript
Plug 'cakebaker/scss-syntax.vim' " SASS
Plug 'heavenshell/vim-jsdoc' " JSDoc
Plug 'JulesWang/css.vim' " CSS
Plug 'genoma/vim-less' " LessCSS
Plug 'kchmck/vim-coffee-script' " CoffeeScript
Plug 'Quramy/tsuquyomi' " TypeScript
Plug 'tpope/vim-rails' " Ruby on rails
Plug 'mattn/emmet-vim'
Plug 'rking/ag.vim'
map <C-f> <esc>:Ag<space>
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-bundler'
Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger="<c-s>"
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'honza/vim-snippets'
Plug 'reinh/vim-makegreen'
Plug 'larsbs/vimtom'
Plug 'tomasr/molokai'
Plug 'freeo/vim-kalisi'
Plug 'airblade/vim-gitgutter'
Plug 'terryma/vim-multiple-cursors'
Plug 'jaxbot/semantic-highlight.vim'
let g:semanticPersistCache=1
Plug 'junegunn/goyo.vim'
Plug 'Raimondi/delimitMate'
Plug 'nathanaelkane/vim-indent-guides'
let g:indent_guides_guide_size = 4
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tacahiroy/ctrlp-funky'
let g:ctrlp_working_path_mode = 2
let g:ctrlp_extensions = ['funky']
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]node_modules$'
\ }
nnoremap <A-p> :CtrlPFunky<Cr>
Plug 'majutsushi/tagbar'
nmap <F4> :TagbarToggle<CR>
Plug 'scrooloose/nerdtree'
let g:NERDTreeWinSize = 25
let g:NERDTreeIgnore = ['^tags$', '^PYSMELLTAGS', '\.pyc$', '__pycache__', 'htmlcov', '.*\.egg-info']
Plug 'dense-analysis/ale'
let g:ale_sign_error = '💥'
let g:ale_sign_warning = '🚫'
highlight clear ALEErrorSign
let g:ale_linters_explicit = 1
let g:ale_fixers = {
\ 'vue': ['prettier'],
\ 'javascript': ['prettier'],
\ 'css': ['prettier'],
\ 'html': ['prettier'],
\ 'python': ['pylint'],
\}
let g:ale_linters = {'python': ['pylint']}
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
Plug 'vim-airline/vim-airline'
let g:airline_powerline_fonts = 1
let g:airline#extensions#ale#enabled = 1
Plug 'ryanoasis/vim-devicons'
let g:webdevicons_enable_nerdtree = 1
let g:webdevicons_enable_airline = 1
let g:webdevicons_enable_ctrlp = 1
let g:WebDevIconsUnicodeDecorateFileNodes = 1
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
let g:NERDTreeHighlightFolders = 1
Plug 'Quramy/vim-js-pretty-template'
call plug#end()
filetype plugin indent on
syntax on
call jspretmpl#register_tag('html', 'html')
autocmd FileType javascript JsPreTmpl html
autocmd FileType javascript.jsx JsPreTmpl html
" == User Interface
set history=1000 " Keep 1000 lines of history
set undolevels=1000
set clipboard+=unnamed
set ruler
set hidden " Don't whine when trying to move away from an unsaved buffer
set showcmd
set showmode
set showmatch " Show matching brackets
set nowrap " Don't wrap long lines
set matchpairs+=<:> " Show matching <> as well
set title
set noerrorbells visualbell t_vb= " No noise
set cursorline " Highlight current line
set mouse=a " Enable the mouse for everything
set cmdheight=2 " Make command line 2 lines high
set laststatus=2 " always show status line
set scrolloff=3 " Keep 3 lines below and above the cursor
set autoread " Autoreload changed files
set winwidth=85
set exrc " Enable project specific vimrc files
set secure " Disable dangerous commands in project specific vimrc
set t_Co=256
set background=dark
colorscheme kalisi
" == Identation and tabs
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=79
set shiftround
set expandtab
set backspace=indent,eol,start
" == Searching
set ignorecase " Ignore case when searching
set smartcase " Ignore case if search pattern is all lowercase,
" Case-sensitive otherwise
set hlsearch " Highlight search terms
nmap <silent> <Leader>/ :nohlsearch<CR>
set incsearch
set gdefault " Search all occurrences by default
set foldmethod=indent " Indentation based folding
set foldlevelstart=99 " Start editing with no fold closed
set wildmenu
set wildmode=longest:full,list
set wildignore+=*/tmp/*,*.bak,*.class,*.aux,*.out,*.toc,*.jpg,*.bmp,*.gif,*.png,*.luac
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.pyc,*.spl,*.sw?,*/htmlcov/*,*/build/*
set nobackup " Backup files are sooo 90's
set noswapfile " Swap files are very annoying
set number
set numberwidth=1
set shortmess+=a
set report=0
set confirm
set encoding=utf8
set showfulltag
set lisp " Autocomplete words separated with a dash
set iskeyword+=-
" don't outdent hashes
inoremap # #
let mapleader=" "
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
let g:showmarks_enable = 1
" Copy to clipboard
map <leader>y "+y
map <leader>c "+y
" Paste from clipboard
map <leader>p "+gp
map <leader>v "+gp
" <Leader>e brings up my .vimrc
" <Leader>E reloads it -- making all changes active (have to save first)
map <leader>e :sp ~/.vimrc<CR><C-W>_
map <silent> <leader>E :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
map <leader>g :YcmCompleter GoToDefinition<CR>
map <leader>G :YcmCompleter GoToDeclaration<CR>
" Format file with Prettier
nmap <Leader>f :ALEFix<CR>
highlight BadWhitespace ctermbg=red guibg=red
let python_highlight_builtin_funcs = 1
let python_print_as_function = 1
let python_highlight_builtin_objs = 1
let python_highlight_doctests = 1
let python_highlight_string_templates = 1
let php_sql_query=1
let php_htmlInStrings=1
let g:php_folding=2
map <silent> <S-F8> :w<CR>:make<CR>:cw<CR>
" let g:molokai_original=1
""" Keybindings
" Disable ex mode
map Q <Nop>
command W w
command Q q
command WQ wq
command Wq wq
" Stuff to piss off vim purists
inoremap <silent> <C-Backspace> <C-w>
inoremap <silent> <C-z> <Esc>:undo<CR>i
inoremap <S-Left> <C-Left>
inoremap <S-Right> <C-Right>
set formatoptions-=t " Don't do automatic linebreaks
map <leader>w :set formatoptions+=t<CR>
" Add support for fakegir (https://github.com/strycore/fakegir/)
if filereadable(expand("~/.cache/fakegir/gi/__init__.py"))
let $PYTHONPATH = expand("~/.cache/fakegir/")
endif
" Add the virtualenv's site-packages to vim path
if has('python')
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
function! FixVimPythonSysModule()
""" Certain modules which rely on sys.real_prefix to exist will raise
""" AttributeErrors on import, and subsequently fail to be imported
""" correctly. Likewise, pythoncomplete won't work correctly when
""" it fails to import a module for whatever reason. This function
""" monkey-patches the sys module to make sure it has a useful
""" 'real_prefix' attribute.
python << EOL
import os, sys
from distutils.sysconfig import get_python_lib
if not hasattr(sys, 'real_prefix'):
sys.real_prefix = os.path.dirname(get_python_lib())
EOL
endfunction
call FixVimPythonSysModule()
endif
" Load up virtualenv's vimrc if it exists
if filereadable($VIRTUAL_ENV . '/.vimrc')
source $VIRTUAL_ENV/.vimrc
endif
set complete-=i " Testing this setting, if not the desired behavior, make this exclusive to FASTVIM
set completeopt=menu,longest,preview
set omnifunc=syntaxcomplete#Complete
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab "Makefiles require hard tabs
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType php setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType xhtml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType html setlocal indentkeys-=*<Return>
autocmd FileType sh nmap <F10> :!. %<CR>
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd Filetype c nmap <F8> :YcmDiags<CR>
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
augroup polymer
autocmd!
if filereadable('./polymer.json')
autocmd FileType html set makeprg=polymer\ lint\ %
map <silent> <F8> :w<CR>:make<CR>:cw<CR>
endif
augroup end
augroup invisible_chars "{{{
autocmd!
" Show invisible characters in all of these files
autocmd filetype vim setlocal list
autocmd filetype python,rst setlocal list
autocmd filetype ruby setlocal list
augroup end "}}}
augroup ruby_files
autocmd!
autocmd BufWritePre *.rb :%s/\s\+$//e " Remove trailing whitespace on save
autocmd BufRead,BufNewFile *.rb SemanticHighlight
augroup end
augroup vim_files "{{{
au!
" Bind <F1> to show the keyword under cursor
" general help can still be entered manually, with :h
autocmd filetype vim noremap <buffer> <F1> <Esc>:help <C-r><C-w><CR>
autocmd filetype vim noremap! <buffer> <F1> <Esc>:help <C-r><C-w><CR>
augroup end "}}}
augroup python_files
autocmd!
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd BufRead,BufNewFile *.py set autoindent sw=4 sts=4 expandtab
autocmd BufRead,BufNewFile *.wsgi setfiletype python
autocmd BufRead *.py SemanticHighlightToggle
autocmd BufWritePre *.py :%s/\s\+$//e " Remove trailing whitespace on save
autocmd BufRead *.py set errorformat=%f:%l:\ %m
autocmd FileType python map <buffer> <F8> :call Flake8()<CR>
" Filetype was set to python.django only for django projects but files
" with the python filetype wouldn't get proper autocompletion. I'm
" suspecting a bug in YouCompleteMe. In the meantime, setting the
" filetype to python.django provide better results for every Python file.
autocmd FileType python set ft=python.django " For SnipMate
if filereadable('./manage.py')
autocmd FileType html set ft=javascript.htmldjango.html " For SnipMate
autocmd BufRead,BufNewFile *.html SemanticHighlight
else
autocmd BufNewFile,BufRead *.py compiler pyunit
nmap <Leader>t :call MakeGreen("%")<CR>
nmap <Leader>T :call MakeGreen(".")<CR>
endif
augroup end
augroup rst_files "{{{
autocmd!
" Auto-wrap text around 74 chars
autocmd filetype rst setlocal formatoptions+=nqt
augroup end " }}}
augroup javascript_files
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType javascript nmap <silent> <leader>j ?function<cr>:noh<cr>:JsDoc<cr>
autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType typescript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType vue setlocal ts=2 sts=2 sw=2 expandtab
autocmd BufRead *.js set makeprg=eslint\ %
autocmd filetype javascript,css setlocal list
autocmd FileType javascript setlocal iskeyword+=$
autocmd BufRead,BufNewFile *.js SemanticHighlight
autocmd BufRead,BufNewFile *.vue SemanticHighlight
augroup end
autocmd FileType htmldjango setlocal ts=2 sts=2 sw=2 expandtab
autocmd BufNewFile,BufRead *.coffee setfiletype coffee
autocmd BufRead *.coffee setfiletype coffee
autocmd FileType coffee setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType coffee set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType html set equalprg=tidy\ -config\ ~/.tidy.conf\ -indent\ -quiet
autocmd FileType html nmap <F10> :!firefox %<CR>
autocmd BufNewFile,BufRead *.rss setfiletype xml
" CSS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType css set equalprg=csstidy
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd BufWritePre *.css :%s/\s\+$//e
autocmd BufWritePre *.less :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
" SASS / SCSS
autocmd BufRead,BufNewFile *.scss set filetype=scss
autocmd FileType scss setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType php set ft=php.html
autocmd FileType php set equalprg=php_beautifier\ -l\ \"Pear()\ ArrayNested()\"\ -s2
autocmd FileType php noremap <C-M> :w!<CR>:!php %<CR> " Run script with php-cli
autocmd FileType php noremap <S-F8> :!php -l %<CR> " php syntax check
autocmd FileType php noremap <F8> :!phpcs %<CR> " php CodeSniffer
" Shortcuts to php-docs
autocmd FileType php inoremap <C-D> <ESC>:call PhpDocSingle()<CR>i
autocmd FileType php nnoremap <C-D> :call PhpDocSingle()<CR>
autocmd FileType php vnoremap <C-D> :call PhpDocRange()<CR>
" Closes the Omni-Completion tip window when a selection is made
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
if has("gui_running")
highlight SpellBad term=underline gui=undercurl guisp=Orange
set guifont=mononoki\ Nerd\ Font\ Mono\ Regular\ 14
set background=dark
autocmd GUIEnter * set visualbell t_vb=
colorscheme vimtom
set guioptions-=T
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=m
set guioptions-=M
endif
if has("gui_macvim")
set guifont=mononoki\ Nerd\ Font:h16
endif
" Highlight long lines
if exists('+colorcolumn')
set colorcolumn=120
highlight ColorColumn ctermbg=darkgray guibg=#4E4E4E
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>91v.\+', -1)
endif
highlight WhitespaceEOL ctermbg=red guibg=red
" Makes a nice vertical separator
set fillchars+=vert:▕
" Invisible characters
set listchars=tab:→\ ,trail:␣,extends:…,eol:⏎
nmap <leader>l :set list!<CR>
map <Leader>s :SemanticHighlightToggle<CR>
map <F9> :SemanticHighlightToggle<CR>
" Creating underline/overline headings for markup languages
" Inspired by http://sphinx.pocoo.org/rest.html#sections
nnoremap <leader>1 yyPVr=jyypVr=
nnoremap <leader>2 yyPVr*jyypVr*
nnoremap <leader>3 yypVr=
nnoremap <leader>4 yypVr-
nnoremap <leader>5 yypVr^
nnoremap <leader>6 yypVr"
" Filetype switching
nmap <leader>fa :filetype detect<CR>
nmap <Leader>fd :set ft=htmldjango.html<CR>
nmap <Leader>fj :set ft=javascript<CR>
nmap <Leader>fh :set ft=html<CR>
" Python & Django helpers
" -----------------------
" Arguments to dict
map <Leader>ad :s#\(\w\+\)=#'\1': #<CR>
" And back again
map <Leader>da :s#'\(\w\+\)'\: #\1=#<CR>
vmap <Leader>tr c{% trans "" %}<Esc>hhhhp
vmap <Leader>bt c{% blocktrans %}<CR>{% endblocktrans %}<Esc>kp
vmap <Leader>% c{% "" %}<Esc>hhhhpF"hi
vmap <Leader>{ c{{ }}<Esc>hhhpi
map <Leader>' ^i'<Esc>ea':<Esc>wi"<Esc>A",<Esc>
" Subsitute fancy quotes to regular quotes
vmap <Leader>qu :s/’/'/e<CR>gv:s/[“”]/"/e<CR>gv
" I think this part remove useless trailing spaces
autocmd BufRead * silent! %s/[\r \t]\+$//
autocmd BufEnter *.php :%s/[ \t\r]\+$//e
map <silent> <A-Right> :tabnext<CR>
map <silent> <A-Left> :tabprevious<CR>
" Jump to prev/next word with Ctrl+right/left
inoremap <C-Right> <C-o>B
inoremap <C-Left> <C-o>W
noremap <silent> <C-Down> <C-T> " Jump to tag
noremap <silent> <C-Up> <C-]> " Jump back from tag
noremap <C-PageUp> gT
noremap <C-pageDown> gt
" json formating
map <leader>jt <Esc>:%!json_xs -f json -t json-pretty<CR>
" Toggle NerdTree
map <silent> <F2> :bdelete<CR>
map <silent> <F3> :NERDTreeToggle<CR>
" Move between buffers
map <silent> <F5> :bprevious<CR>
map <silent> <F6> :bnext<CR>
" Toggle paste mode
set pastetoggle=<F7>
" Search with Zeal
nnoremap gz :!zeal --query "<cword>"&<CR><CR>
" Save file with sudo
cmap w!! w !sudo tee % > /dev/null
set path=$PWD/**
let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'
let s:minfontsize = 6
let s:maxfontsize = 16
function! AdjustFontSize(amount)
if has("gui_running")
let fontname = substitute(&guifont, s:pattern, '\1', '')
let cursize = substitute(&guifont, s:pattern, '\2', '')
let newsize = cursize + a:amount
if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize)
let newfont = fontname . newsize
let &guifont = newfont
endif
else
echoerr "You need to run the GUI version of Vim to use this function."
endif
endfunction
function! LargerFont()
call AdjustFontSize(1)
endfunction
command! LargerFont call LargerFont()
function! SmallerFont()
call AdjustFontSize(-1)
endfunction
command! SmallerFont call SmallerFont()
map <silent> <C-S-Up> :LargerFont<CR>
map <silent> <C-S-Down> :SmallerFont<CR>