]> git.rmz.io Git - dotfiles.git/blob - vim/vimrc
awesome: format theme.lua
[dotfiles.git] / vim / vimrc
1 " My vimrc.
2 "
3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
4 "
5
6 " plugins {{{1
7 filetype off
8 set runtimepath& " reset rtp
9 " remove all autocommands
10 autocmd!
11
12 set runtimepath+=$XDG_DATA_HOME/vim/vundle
13 call vundle#rc('$XDG_DATA_HOME/vim')
14
15 Plugin 'gmarik/vundle'
16
17 Plugin 'airblade/vim-gitgutter'
18 Plugin 'bling/vim-airline'
19 Plugin 'derekwyatt/vim-fswitch'
20 Plugin 'elzr/vim-json'
21 Plugin 'firef0x/pkgbuild.vim'
22 Plugin 'junegunn/vim-easy-align'
23 " Plugin 'kien/ctrlp.vim'
24 " Plugin 'klen/python-mode'
25 Plugin 'wilywampa/python-mode'
26 Plugin 'kshenoy/vim-signature'
27 Plugin 'majutsushi/tagbar'
28 Plugin 'raimondi/delimitmate'
29 " Plugin 'rking/ag.vim'
30 Plugin 'scrooloose/nerdtree'
31 Plugin 'scrooloose/syntastic'
32 Plugin 'shougo/vimproc.vim'
33 Plugin 'shougo/unite.vim'
34 Plugin 'sjl/gundo.vim'
35 Plugin 'tomtom/tcomment_vim'
36 Plugin 'tpope/vim-endwise'
37 Plugin 'tpope/vim-fugitive'
38 Plugin 'tpope/vim-repeat'
39 Plugin 'tpope/vim-surround'
40 Plugin 'tpope/vim-unimpaired'
41 Plugin 'valloric/youcompleteme'
42 Plugin 'vim-scripts/yankring.vim'
43
44 " snippets
45 Plugin 'sirver/ultisnips'
46 Plugin 'honza/vim-snippets'
47
48 " text objects
49 Plugin 'kana/vim-textobj-user'
50 Plugin 'julian/vim-textobj-variable-segment'
51 Plugin 'sgur/vim-textobj-parameter'
52
53 " ros
54 Plugin 'ompugao/ros.vim'
55 Plugin 'ompugao/ctrlp-ros'
56
57 " seems to have problems right now... may be add later?
58 " Plugin 'jalcine/cmake.vim'
59 " Plugin 'powerman/vim-plugin-viewdoc'
60
61 " staging
62 " find an alternative (latex-box? Automatic Latex Plugin?)
63 Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex'
64 " Plugin 'lokaltog/vim-easymotion'
65 Plugin 'justinmk/vim-sneak'
66 Plugin 'chrisbra/checkattach'
67 Plugin 'nathanaelkane/vim-indent-guides'
68 Plugin 'alx741/vinfo'
69 Plugin 'octol/vim-cpp-enhanced-highlight'
70 Plugin 'vim-scripts/mediawiki.vim'
71 Plugin 'vim-scripts/replacewithregister'
72 Plugin 'tpope/vim-abolish'
73
74 " remove entries first
75 set runtimepath -=$HOME/.vim
76 set runtimepath -=$HOME/.vim/after
77 set runtimepath -=$XDG_CONFIG_HOME/vim
78 set runtimepath -=$XDG_CONFIG_HOME/vim/after
79 " then prepend and append them
80 set runtimepath ^=$XDG_CONFIG_HOME/vim
81 set runtimepath +=$XDG_CONFIG_HOME/vim/after
82
83 filetype plugin indent on
84
85 " colorscheme {{{1
86 syntax on
87 colorscheme badwolf
88
89 " options {{{1
90 " moving around, searching and patterns {{{2
91 set incsearch " show match for partly typed search command
92 set ignorecase " ignore case when using a search pattern
93 set smartcase " override 'ignorecase' when pattern has upper case characters
94 set hlsearch " highlight all matches for the last used search pattern
95
96 set nostartofline " don't move the cursor to the first non-blank char of a line
97 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
98
99 " displaying text {{{2
100 set scrolloff=5 " number of screen lines to show around the cursor
101 set nowrap " long lines wrap
102 set linebreak " wrap long lines at a character in 'breakat'
103 set showbreak=↪ " show these chars for wrapped lines
104
105 set lazyredraw " don't redraw while executing macros
106
107 set list " show chars defined in 'listchars'
108 set listchars=tab:❭\ " list of strings used for list mode
109 set listchars+=extends:❯,precedes:❮
110 " Only shown when not in insert mode
111 augroup trailing
112 au!
113 au InsertEnter * :set listchars-=trail:·
114 au InsertLeave * :set listchars+=trail:·
115 augroup END
116
117 set sidescroll=1 " number of collumns to scroll
118 set sidescrolloff=1 " don't scroll over the listchars
119
120 set fillchars=diff:⣿,vert:│
121
122 set nonumber " show the line number for each line
123 set norelativenumber " show the relative line number for each line
124
125 " syntax, highlighting and spelling {{{2
126 set synmaxcol=800 " don't highlight long lines
127
128 set dictionary=spell " list of dictionary files for keyword completion
129
130 set colorcolumn=+1
131
132 " multiple windows {{{2
133 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
134
135 set previewheight=20 " default height for the preview window
136
137 set hidden
138
139 " set splitbelow " a new window is put below of the current one
140 set splitright " a new window is put right of the current one
141
142 " terminal {{{2
143 set ttyfast
144
145 " using the mouse {{{2
146 set mouse=rnv " list of flags for using the mouse
147 set ttymouse=xterm " type of mouse
148
149 " messages and info {{{2
150 set showcmd " Show (partial) command in status line.
151 set ruler " show the cursor position all the time
152 set confirm " Ask what to do when closing unsaved documents
153 set shortmess=filnxtoOI " don't show intro message
154
155 " editing text {{{2
156 set backspace=indent,eol,start " allow backspacing over everything in insert mode
157
158 set showmatch " Show matching brackets.
159
160 set nojoinspaces " don't use two spaces after '.' when joining a line
161 set formatoptions=jcrnql
162
163 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
164
165 set complete=.,w,b,u,t
166 " whether to use a popup menu for Insert mode completion
167 set completeopt=longest,menuone,preview
168
169 " tabs and indent {{{2
170 set shiftwidth=4 " number of spaces used for each step of (auto)indent
171 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
172 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
173 set shiftround " round to 'shiftwidth' for "<<" and ">>"
174 set expandtab " expand <Tab> to spaces in Insert mode
175 set autoindent
176
177 set pastetoggle=<F11> " key sequence to toggle paste mode
178
179 " folding {{{2
180 set foldmethod=marker " folding type
181 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
182
183 " save and restore folds
184 set viewoptions=cursor " only save cursor position
185
186 " diff mode {{{2
187 set diffopt=filler,vertical
188
189 " reading and writing files {{{2
190 set modeline " read modelines
191 set modelines=2 " only check first/last 2 lines
192
193 set writebackup " write a backup file before overwriting a file
194 set backup " keep a backup after owerwriting a file
195 set backupdir=$XDG_CACHE_HOME/vim/backup//
196
197 set backupskip+=.netrc " skip netrc
198 set backupskip+=/dev/shm/pass* " skip passwordstore files
199
200 set undofile " persistent undo history
201 set undodir=$XDG_CACHE_HOME/vim/undo//
202
203 augroup undoskip
204 au!
205 au BufWritePre .netrc setlocal noundofile
206 au BufWritePre /dev/shm/pass* setlocal noundofile
207 au BufWritePre /tmp/* setlocal noundofile
208 augroup END
209
210 set autowrite " automatically write a file when leaving a modified buffer
211 set autoread " automatically read a file that has been modified
212
213 " the swap file {{{2
214 set noswapfile
215 set directory=$XDG_CACHE_HOME/vim/swap//
216
217 " command line editing {{{2
218 set history=5000 " how many command lines are remembered
219 set wildmenu " command-line completion shows a list of matches
220 set wildmode=longest:full,full " specifies how command line completion works
221
222 set wildignore+=.hg,.git,.svn " Version control
223 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
224 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
225 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
226 set wildignore+=*.spl " compiled spelling word lists
227 set wildignore+=*.sw? " Vim swap files
228 set wildignore+=*.luac " Lua byte code
229 set wildignore+=*.pyc " Python byte code
230 set wildignore+=*.orig " Merge resolution files
231
232 " various {{{2
233 set virtualedit=block " let cursor move past last char in <C-V> mode
234 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
235
236 set viewdir=$XDG_CACHE_HOME/vim/view//
237
238 " autocmds {{{1
239 " Resize splits when the window is resized {{{2
240 augroup resize
241 au!
242 autocmd VimResized * :wincmd =
243 augroup END
244
245 " Only show cursorline in the current window and in normal mode {{{2
246 augroup cline
247 au!
248 au WinLeave,InsertEnter * set nocursorline
249 au WinEnter,InsertLeave * set cursorline
250 augroup END
251
252 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
253 augroup ft_stdin
254 au!
255 au StdinReadPost * :set buftype=nofile
256 augroup END
257
258 " Jump to last known cursor position {{{2
259 augroup cursor_pos
260 au!
261 " blacklist certain filetype
262 let blacklist = ['gitcommit']
263 autocmd BufReadPost *
264 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
265 \ exe "normal! g`\"" |
266 \ endif
267 augroup END
268
269 " bindings {{{1
270
271 " allow both <space> and / to be <leader>
272 map <space> <leader>
273
274 " make
275 nnoremap <leader>r :make<cr>
276 nnoremap <leader><cr> :make<cr>
277
278 " unhighlight search
279 nnoremap <silent> <Leader>/ :silent nohl<CR>
280
281 " Tabs
282 nnoremap <leader>[ :tabprev<cr>
283 nnoremap <leader>] :tabnext<cr>
284
285 " paste from selection
286 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
287 " paste from clipboard
288 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
289
290 " Clean trailing whitespace
291 nnoremap <silent> <leader>ww m':%s/\s\+$//<cr>:let @/=''<cr>``zz
292
293 " Source
294 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
295 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
296
297 " jump to last cursor position
298 noremap ' `
299
300 " Select (charwise) the contents of the current line, excluding indentation.
301 nnoremap vv ^vg_
302
303 " Unfuck my screen
304 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
305
306 " Ranger
307 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
308 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
309
310 " Use sane regexes.
311 nnoremap / /\v
312 vnoremap / /\v
313 cnoremap s/ s/\v
314
315 " display the number of matches for the last search
316 nmap <Leader># :%s:<C-R>/::gn<CR>
317
318 " center cursor after search and open folds
319 nnoremap n nzzzv
320 nnoremap N Nzzzv
321
322 " same when jumping around
323 nnoremap g; g;zzzv
324 nnoremap g, g,zzzv
325 nnoremap <c-o> <c-o>zzzv
326 nnoremap <c-i> <c-i>zzzv
327
328 " Not using the default mappings of 'To line from top/bottom'
329 noremap H ^
330 noremap L $
331 vnoremap H ^
332 vnoremap L g_
333
334 " Heresy, emacs insert bindings
335 inoremap <c-a> <esc>I
336 inoremap <c-e> <esc>A
337 cnoremap <c-a> <home>
338 cnoremap <c-e> <end>
339
340 " proper movement when lines are wrapped
341 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
342 noremap <expr> k (v:count == 0 ? 'gk' : 'k')
343
344 " disable arrows
345 noremap <Up> <NOP>
346 noremap <Down> <NOP>
347 noremap <Left> <NOP>
348 noremap <Right> <NOP>
349 inoremap <Up> <NOP>
350 inoremap <Down> <NOP>
351 inoremap <Left> <NOP>
352 inoremap <Right> <NOP>
353 cnoremap <Up> <NOP>
354 cnoremap <Down> <NOP>
355 cnoremap <Left> <NOP>
356 cnoremap <Right> <NOP>
357 cnoremap <C-K> <Up>
358 cnoremap <C-J> <Down>
359 cnoremap <C-H> <Left>
360 cnoremap <C-L> <Right>
361
362 " close all folds open fold in cursor
363 nnoremap zx zMzxzt
364
365 map <F1> :ls<CR>:b<space>
366
367 nnoremap <C-L> <C-W>w
368 nnoremap <C-H> <C-W>W
369
370 "xterm mouse with middleclick paste
371 nnoremap <MiddleMouse> i<MiddleMouse>
372 vnoremap <MiddleMouse> s<MiddleMouse>
373
374 " fix legacy vi inconsistency
375 map Y y$
376
377 " allow repeat operator on visual
378 vnoremap . :normal .<CR>
379
380 " add line without changing position or leaving mode
381 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
382 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
383
384 " Don't use Ex mode, use Q for formatting
385 map Q gq
386
387 " break undo sequence before removing word
388 inoremap <C-W> <C-G>u<C-W>
389
390 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
391 nnoremap [oe :set expandtab<CR>
392 nnoremap ]oe :set noexpandtab<CR>
393
394 for idt in range(1,8)
395 exe 'nnoremap co'.idt.' :set tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
396 endfor
397
398 " space will toggle current fold in normal mode
399 nnoremap <leader><Space> za
400 " create folds around visual selection
401 vnoremap <leader><Space> zf
402
403 autocmd BufWinLeave *.* mkview
404 autocmd BufWinEnter *.* silent loadview
405
406 " save with sudo
407 cnoremap w!! w !sudo tee % > /dev/null
408
409 " uppercase previous word
410 inoremap <C-C> <Esc>gUiwgi
411
412 " plugins options {{{1
413 " airline {{{2
414 let g:airline#extensions#whitespace#enabled = 1
415 let g:airline#extensions#tabline#enabled = 1
416 let g:airline_powerline_fonts = 1
417
418 " checkattach {{{2
419 let g:checkattach_filebrowser = 'ranger'
420 let g:checkattach_once = 'y'
421
422 " delimitmate {{{2
423 let delimitMate_expand_cr = 2
424 let g:delimitMate_expand_space = 1
425
426 " fswitch {{{2
427 nnoremap <silent> <Leader>ff :FSHere<CR>
428 nnoremap <silent> <Leader>fl :FSRight<CR>
429 nnoremap <silent> <Leader>fh :FSLeft<CR>
430 nnoremap <silent> <Leader>fj :FSBelow<CR>
431 nnoremap <silent> <Leader>fk :FSAbove<CR>
432 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
433 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
434 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
435 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
436
437 " fugitive {{{2
438 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
439 " delete fugitive buffers when closed
440 autocmd BufReadPost fugitive://* set bufhidden=delete
441
442 nnoremap <silent> <leader>gs :Gstatus<CR>
443 nnoremap <silent> <leader>gd :Gdiff<CR>
444 nnoremap <silent> <leader>gc :Gcommit -v<CR>
445 nnoremap <silent> <leader>ga :Gwrite<cr>
446 nnoremap <silent> <leader>gb :Gblame<cr>
447
448 " Gundo {{{2
449 nnoremap <F7> :GundoToggle<CR>
450
451 " indent-guides {{{2
452 let g:indent_guides_default_mapping = 0
453 let g:indent_guides_guide_size = 1
454 nmap <silent> cog <Plug>IndentGuidesToggle
455 nmap <silent> [og <Plug>IndentGuidesEnable
456 nmap <silent> ]og <Plug>IndentGuidesDisable
457
458 " NERDTree {{{2
459 " open/close NERDTree with \e
460 nmap <Leader>e :NERDTreeToggle<CR>
461 nmap <F6> :NERDTreeToggle<CR>
462 " <space> to open files/dirs
463 let NERDTreeMapActivateNode='l'
464 " close vim if only NERDTree is open
465 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
466
467 " python-mode {{{2
468
469 let g:pymode_rope_completion = 0
470 let g:pymode_rope = 0
471 let g:pymode_folding = 1
472 let g:pymode_lint_ignore = "E221,E266,E501"
473 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
474
475 " synastic {{{2
476 let g:syntastic_enable_highlighting = 0
477 let g:syntastic_error_symbol='E'
478 let g:syntastic_style_error_symbol='S'
479 let g:syntastic_warning_symbol='W'
480 let g:syntastic_style_warning_symbol='S'
481 let g:syntastic_always_populate_loc_list=1
482 nmap <silent> <leader>y :SyntasticCheck<cr>
483
484 if ! &diff
485 let g:syntastic_check_on_open=1
486 endif
487
488 " tagbar {{{2
489 map <F5> :TagbarToggle<cr>
490 let g:tagbar_sort = 0
491 let g:tagbar_compact = 1
492 let g:tagbar_autoshowtag = 1
493 let g:tagbar_width = 25
494 let g:tagbar_iconchars = ['+', '-']
495
496 " ultisnips {{{2
497 let g:UltiSnipsEditSplit = 'vertical'
498 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
499 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
500 let g:UltiSnipsExpandTrigger = "<tab>"
501 let g:UltiSnipsJumpForwardTrigger = "<tab>"
502 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
503
504 " UltiSnips completion function that tries to expand a snippet. If there's no
505 " snippet for expanding, it checks for completion window and if it's shown,
506 " selects first element. If there's no completion window it tries to jump to
507 " next placeholder. If there's no placeholder it just returns TAB key
508 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
509 function! g:UltiSnips_Complete()
510 call UltiSnips#ExpandSnippet()
511 if g:ulti_expand_res == 0
512 if pumvisible()
513 return "\<C-n>"
514 else
515 call UltiSnips#JumpForwards()
516 if g:ulti_jump_forwards_res == 0
517 return "\<TAB>"
518 endif
519 endif
520 endif
521 return ""
522 endfunction
523 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
524 let g:UltiSnipsListSnippets="<c-e>"
525
526 " unite {{{2
527 call unite#filters#matcher_default#use(['matcher_fuzzy'])
528 call unite#custom#profile('default', 'context', {
529 \ 'winheight': 20,
530 \ 'direction': 'botright'
531 \ })
532
533 nnoremap [unite] <Nop>
534 nmap <leader>u [unite]
535
536 " unite-grep {{{3
537 " seems not respected
538 let g:unite_source_grep_max_candidates = 2000
539 if executable('ag')
540 " Use ag in unite grep source.
541 let g:unite_source_grep_command = 'ag'
542 let g:unite_source_grep_default_opts = '--smart-case -w --vimgrep --hidden --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
543 let g:unite_source_grep_recursive_opt = ''
544 end
545 nnoremap <silent> [unite]a :<C-u>Unite grep -input=\12\17<CR>
546 command! -nargs=1 Ag Unite grep -input=<args>
547
548 " unite-file_rec {{{3
549 if executable('ag')
550 " Use ag in unite rec source
551 let g:unite_source_rec_async_command = 'ag --follow --nocolor --nogroup --hidden -g ""'
552 end
553 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
554
555 " unite-buffer {{{3
556 call unite#custom#default_action('buffer', 'goto')
557 nnoremap <silent> [unite]b :<C-u>Unite buffer<CR>
558
559 " unite-menu {{{3
560 let g:unite_source_menu_menus = {}
561 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
562 let g:unite_source_menu_menus.fugitive.command_candidates = {
563 \ 'Gstatus <Leader>gs' : 'Gstatus',
564 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
565 \ 'Glog' : 'Glog',
566 \}
567
568 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
569
570 let g:unite_source_history_yank_enable = 1
571 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
572
573 " yankring {{{2
574 nnoremap <silent> <leader>p :YRShow<cr>
575 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
576 let g:yankring_replace_n_pkey = ''
577 let g:yankring_replace_n_nkey = ''
578
579 " map Y to y$ for the yank ring
580 function! YRRunAfterMaps()
581 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
582 endfunction
583
584 " youcompleteme {{{2
585 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
586 let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
587 let g:ycm_extra_conf_vim_data = ['getcwd()']
588 let g:ycm_add_preview_to_completeopt = 1
589 let g:ycm_autoclose_preview_window_after_insertion = 0
590 "let g:ycm_extra_conf_vim_data = ['%:p']
591 nnoremap <leader>jd :YcmCompleter GoTo<CR>
592
593 " vim-easy-align {{{2
594 " start interactive EasyAlign in visual mode
595 vmap <Enter> <Plug>(EasyAlign)
596
597 " vim-json {{{2
598 let g:vim_json_syntax_conceal = 0
599
600 " vim-latex {{{2
601 let g:tex_flavor='latex'
602 let g:Tex_DefaultTargetFormat='pdf'
603 let g:Tex_MultipleCompileFormats='pdf'
604
605 " vim-sneak {{{2
606 let g:sneak#streak = 1
607 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
608 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
609
610 " sneaky f and t
611 nmap f <Plug>Sneak_f
612 nmap F <Plug>Sneak_F
613 xmap f <Plug>Sneak_f
614 xmap F <Plug>Sneak_F
615 omap f <Plug>Sneak_f
616 omap F <Plug>Sneak_F
617 nmap t <Plug>Sneak_t
618 nmap T <Plug>Sneak_T
619 xmap t <Plug>Sneak_t
620 xmap T <Plug>Sneak_T
621 omap t <Plug>Sneak_t
622 omap T <Plug>Sneak_T
623
624 " functions {{{1
625
626 " Convenient command to see the difference between the current buffer and the
627 " file it was loaded from, thus the changes you made.
628 " Only define it when not defined already.
629 if !exists(":DiffOrig")
630 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
631 \ | wincmd p | diffthis
632 endif
633
634 " edit configs {{{2
635 function! EditConfig(what)
636 let l:dir = split(&runtimepath,',')[0]
637 if a:what == 'vimrc'
638 let l:file = expand($MYVIMRC)
639 elseif ! isdirectory(globpath(l:dir, a:what))
640 echoe a:what." is not valid!"
641 elseif empty(&filetype)
642 echoe 'filetype is empty!'
643 else
644 let l:file = l:dir.'/'.a:what.'/'.&filetype.'.vim'
645 endif
646
647 execute ':vsplit '.file
648 execute ':lcd %:p:h'
649 endf
650 nmap <leader>ev :call EditConfig('vimrc')<CR>
651 nmap <leader>ef :call EditConfig('ftplugin')<CR>
652 nmap <leader>es :call EditConfig('syntax')<CR>
653 nmap <leader>ei :call EditConfig('indent')<CR>
654 nmap <leader>eu :UltiSnipsEdit<CR>:lcd %:p:h<CR>
655
656 " spell check {{{2
657 " http://tex.stackexchange.com/a/52932
658 let g:myLangList=["en_gb","en_us","de","fr"]
659
660 function! ToggleSpell()
661 if !exists("b:myLang")
662 let b:myLang=0
663 endif
664 execute "setlocal spell!"
665 if (&spell)
666 echo "setlocal spelllang=" g:myLangList[b:myLang]
667 endif
668 endfunction
669
670 function! SwitchSpell()
671 if !exists("b:myLang")
672 let b:myLang=0
673 endif
674 if (&spell)
675 let b:myLang=b:myLang+1
676 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
677 endif
678 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
679 echo "setlocal spelllang=" g:myLangList[b:myLang]
680 endfunction
681
682 nnoremap <silent> coS :call SwitchSpell()<CR>
683 " fix spelling with first choice
684 nnoremap <Leader>f 1z=