Mercurial > dotfiles
changeset 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 | 0ca43d601919 |
children | 72365ec18f54 |
files | vim/vimrc |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/vim/vimrc Wed Dec 20 09:19:14 2017 -0800 +++ b/vim/vimrc Thu Jan 18 16:24:47 2018 -0800 @@ -475,6 +475,8 @@ au! autocmd FileType c,c++,cpp setlocal foldmethod=syntax autocmd FileType c,c++,cpp setlocal colorcolumn=120 + autocmd FileType c,c++,cpp setlocal synmaxcol=200 + autocmd FileType c,c++,cpp nnoremap <buffer> <localleader>z :call <SID>ToggleCppFolding()<CR> augroup END augroup VimRCFileType_csharp @@ -482,6 +484,7 @@ autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml autocmd FileType cs setlocal foldmethod=syntax autocmd FileType cs setlocal colorcolumn=120 + autocmd FileType cs setlocal synmaxcol=200 augroup END augroup VimRCFileType_css @@ -705,6 +708,13 @@ " Create folds with <space> (in visual mode). vnoremap <space> zf +" See http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text +" Don't screw up folds when inserting text that might affect them, until +" leaving insert mode. Foldmethod is local to the window. Protect against +" screwing up folding when switching between windows. +autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif +autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif + " }}} " Abbreviations {{{ @@ -745,6 +755,16 @@ normal zz endfunction +function! s:ToggleCppFolding() abort + if (&foldmethod == "syntax") + setlocal foldmethod=manual + setlocal nofoldenable + else + setlocal foldmethod=syntax + setlocal foldenable + endif +endfunction + " }}} " Local override {{{