aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/config/format.vim10
1 files changed, 10 insertions, 0 deletions
diff --git a/vim/config/format.vim b/vim/config/format.vim
index fe13d25b..35245d0d 100644
--- a/vim/config/format.vim
+++ b/vim/config/format.vim
@@ -20,16 +20,26 @@ endif
" very handy
"
if has('eval')
+
+ " Declare function
function! s:ToggleFormatFlag(flag)
+
+ " Decide on whether we're adding or removing the flag
if &l:formatoptions =~# a:flag
let l:command = 'setlocal formatoptions-=' . a:flag
else
let l:command = 'setlocal formatoptions+=' . a:flag
endif
+
+ " Execute the command we determined and show the result
silent! execute l:command
setlocal formatoptions?
+
endfunction
+
+ " Map leader-letters to corresponding format option flags
nnoremap <silent> <leader>a :<C-U>call <SID>ToggleFormatFlag('a')<CR>
nnoremap <silent> <leader>c :<C-U>call <SID>ToggleFormatFlag('c')<CR>
nnoremap <silent> <leader>t :<C-U>call <SID>ToggleFormatFlag('t')<CR>
+
endif