" All of this variable logic requires 'eval', and I can't just short-circuit " it due to a quirk in the way vim-tiny evaluates these expressions if has('eval') " Figure out if we have the 'j' flag for 'formatoptions', to automatically " delete comment leaders when joining lines; keep it in a script variable let s:formatoptions_has_j = v:version > 703 \ || v:version == 703 && has('patch541') " If we do have 'j', default to setting it if s:formatoptions_has_j set formatoptions+=j endif " " Use toggle_option_flag.vim plugin to bind quick toggle actions for some " 'formatoptions' flags; both of the above, plus: " " c - Automatically wrap comments at 'textwidth' (which I allow the filetypes " to set for me) " t - Automatically wrap text at 'textwidth' (as above) " " We need user-defined commands to do this. " if !has('user_commands') finish endif " 'c' and 't' have both been around since at least 6.1 nnoremap \ c \ :ToggleOptionFlagLocal formatoptions c nnoremap \ t \ :ToggleOptionFlagLocal formatoptions t " Figure out if we have the 'a' flag for 'formatoptions', to reapply " 'textwidth' wrapping to the current paragraph on every insertion or " deletion; keep in a script variable let s:formatoptions_has_a = v:version > 610 \ || v:version == 610 && has('patch142') " 'a' needs testing if s:formatoptions_has_a nnoremap \ a \ :ToggleOptionFlagLocal formatoptions a else nnoremap \ a \ :echoerr 'No formatoptions a-flag' endif " 'j' needs testing if s:formatoptions_has_j nnoremap \ j \ :ToggleOptionFlagLocal formatoptions j else nnoremap \ j \ :echoerr 'No formatoptions j-flag' endif endif