diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-05 01:16:46 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-05 01:16:46 +1300 |
commit | 9e20cbd7294ef76d2b7270b56af59fb82fea5785 (patch) | |
tree | def22a091e6cffe7969f5559ce2e5b23b9720a1a /vim/config | |
parent | Merge branch 'feature/vim-lint-autoload' into develop (diff) | |
download | dotfiles-9e20cbd7294ef76d2b7270b56af59fb82fea5785.tar.gz dotfiles-9e20cbd7294ef76d2b7270b56af59fb82fea5785.zip |
Block 'formatoptions' 'a' flag on old Vim versions
If I ever care, this needs more careful testing to find the version in
which the flag was added.
Diffstat (limited to 'vim/config')
-rw-r--r-- | vim/config/format.vim | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/vim/config/format.vim b/vim/config/format.vim index 688b60c9..40019d0a 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -9,22 +9,36 @@ endif " Use toggle_option_flag.vim plugin to bind quick toggle actions for some " 'formatoptions' flags: " +" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes +" to set for me) +" t - Automatically wrap text at 'textwidth' (as above) +" +" Only in Vim >= 7.1 (I think): +" " a - Automatically format paragraphs, reapplying the wrap on every text " insertion or deletion; sometimes I want this and sometimes I " don't, it particularly varies when typing prose in Markdown that " includes headings and code -" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes -" to set for me) -" t - Automatically wrap text at 'textwidth' (as above) " if has('eval') && has('user_commands') - nnoremap <silent> - \ <Leader>a - \ :<C-U>ToggleOptionFlagLocal formatoptions a<CR> + + " 'c' and 't' have both been around since at least 6.1 nnoremap <silent> \ <Leader>c \ :<C-U>ToggleOptionFlagLocal formatoptions c<CR> nnoremap <silent> \ <Leader>t \ :<C-U>ToggleOptionFlagLocal formatoptions t<CR> + + " 'a' is newer + if v:version >= 701 + nnoremap <silent> + \ <Leader>a + \ :<C-U>ToggleOptionFlagLocal formatoptions a<CR> + else + nnoremap <silent> + \ <Leader>a + \ :<C-U>echomsg 'No "formatoptions" "a" flag in Vim < 7.1'<CR> + endif + endif |