Mercurial > dotfiles
comparison vim/vimrc @ 413:4a2468f72e44
Optimize C++ file editing with some folding tricks.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 18 Jan 2018 16:24:47 -0800 |
parents | 5bbd5963591c |
children | 72365ec18f54 |
comparison
equal
deleted
inserted
replaced
412:0ca43d601919 | 413:4a2468f72e44 |
---|---|
473 | 473 |
474 augroup VimRCFileType_c | 474 augroup VimRCFileType_c |
475 au! | 475 au! |
476 autocmd FileType c,c++,cpp setlocal foldmethod=syntax | 476 autocmd FileType c,c++,cpp setlocal foldmethod=syntax |
477 autocmd FileType c,c++,cpp setlocal colorcolumn=120 | 477 autocmd FileType c,c++,cpp setlocal colorcolumn=120 |
478 autocmd FileType c,c++,cpp setlocal synmaxcol=200 | |
479 autocmd FileType c,c++,cpp nnoremap <buffer> <localleader>z :call <SID>ToggleCppFolding()<CR> | |
478 augroup END | 480 augroup END |
479 | 481 |
480 augroup VimRCFileType_csharp | 482 augroup VimRCFileType_csharp |
481 au! | 483 au! |
482 autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml | 484 autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml |
483 autocmd FileType cs setlocal foldmethod=syntax | 485 autocmd FileType cs setlocal foldmethod=syntax |
484 autocmd FileType cs setlocal colorcolumn=120 | 486 autocmd FileType cs setlocal colorcolumn=120 |
487 autocmd FileType cs setlocal synmaxcol=200 | |
485 augroup END | 488 augroup END |
486 | 489 |
487 augroup VimRCFileType_css | 490 augroup VimRCFileType_css |
488 au! | 491 au! |
489 autocmd BufNewFile,BufRead *.less setlocal filetype=less | 492 autocmd BufNewFile,BufRead *.less setlocal filetype=less |
703 nnoremap <space> za | 706 nnoremap <space> za |
704 | 707 |
705 " Create folds with <space> (in visual mode). | 708 " Create folds with <space> (in visual mode). |
706 vnoremap <space> zf | 709 vnoremap <space> zf |
707 | 710 |
711 " See http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text | |
712 " Don't screw up folds when inserting text that might affect them, until | |
713 " leaving insert mode. Foldmethod is local to the window. Protect against | |
714 " screwing up folding when switching between windows. | |
715 autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif | |
716 autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif | |
717 | |
708 " }}} | 718 " }}} |
709 | 719 |
710 " Abbreviations {{{ | 720 " Abbreviations {{{ |
711 | 721 |
712 iabbrev @@ ludovic@chabant.com | 722 iabbrev @@ ludovic@chabant.com |
743 function! s:FindInNERDTree() abort | 753 function! s:FindInNERDTree() abort |
744 ProjectRootExe NERDTreeFind | 754 ProjectRootExe NERDTreeFind |
745 normal zz | 755 normal zz |
746 endfunction | 756 endfunction |
747 | 757 |
758 function! s:ToggleCppFolding() abort | |
759 if (&foldmethod == "syntax") | |
760 setlocal foldmethod=manual | |
761 setlocal nofoldenable | |
762 else | |
763 setlocal foldmethod=syntax | |
764 setlocal foldenable | |
765 endif | |
766 endfunction | |
767 | |
748 " }}} | 768 " }}} |
749 | 769 |
750 " Local override {{{ | 770 " Local override {{{ |
751 | 771 |
752 let s:local_vimrc = s:vim_home.'/vimrc-local' | 772 let s:local_vimrc = s:vim_home.'/vimrc-local' |