aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-30 22:47:13 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-30 22:47:13 +1300
commit639483ec52dca56440fb0cd787bb48c6bf3167d2 (patch)
tree2bc2a6f6967ba8a857634fa868b71615605ad4c3
parentMove execution out of 'formatoptions' conditional (diff)
downloaddotfiles-639483ec52dca56440fb0cd787bb48c6bf3167d2.tar.gz
dotfiles-639483ec52dca56440fb0cd787bb48c6bf3167d2.zip
Add some comments to 'formatoptions' switching
Just for clarity of reading.
-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