From 08f3a956d09f64acdcd79cf7b312b2416e60dfc6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jun 2018 20:52:13 +1200 Subject: Refine 'comments' ftplugins further Add 'formatoptions' flags 'o' and 'r' to all four configured types. This is especially important for block comments in PHP. --- vim/after/ftplugin/awk/comments.vim | 13 +++++++------ vim/after/ftplugin/php/comments.vim | 22 ++++++++++++++++++++++ vim/after/ftplugin/sed/comments.vim | 13 +++++++------ vim/after/ftplugin/sh/comments.vim | 7 ++++--- 4 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 vim/after/ftplugin/php/comments.vim (limited to 'vim/after') diff --git a/vim/after/ftplugin/awk/comments.vim b/vim/after/ftplugin/awk/comments.vim index 5f91bef2..caf11679 100644 --- a/vim/after/ftplugin/awk/comments.vim +++ b/vim/after/ftplugin/awk/comments.vim @@ -1,4 +1,4 @@ -" awk/comments.vim: Set 'comments' for AWK +" awk/comments.vim: Set 'comments' and supporting 'formatoptions' for AWK " Don't load if running compatible or too old if &compatible || v:version < 700 @@ -6,16 +6,17 @@ if &compatible || v:version < 700 endif " Don't load if already loaded -if exists('b:did_ftplugin_awk_format') +if exists('b:did_ftplugin_awk_comments') finish endif " Flag as loaded -let b:did_ftplugin_awk_format = 1 +let b:did_ftplugin_awk_comments = 1 let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_awk_format' + \ . '|unlet b:did_ftplugin_awk_comments' -" Use trailing whitespace to denote continued paragraph +" Set comment formats setlocal comments=:# +setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' + \ . '|setlocal comments< formatoptions<' diff --git a/vim/after/ftplugin/php/comments.vim b/vim/after/ftplugin/php/comments.vim new file mode 100644 index 00000000..9d233560 --- /dev/null +++ b/vim/after/ftplugin/php/comments.vim @@ -0,0 +1,22 @@ +" php/comments.vim: Set 'comments' and supporting 'formatoptions' for PHP + +" Don't load if running compatible or too old +if &compatible || v:version < 700 + finish +endif + +" Don't load if already loaded +if exists('b:did_ftplugin_php_comments') + finish +endif + +" Flag as loaded +let b:did_ftplugin_php_comments = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_php_comments' + +" Set comment formats +setlocal comments=s1:/*,m:*,ex:*/,://,:# +setlocal formatoptions+=or +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal comments< formatoptions<' diff --git a/vim/after/ftplugin/sed/comments.vim b/vim/after/ftplugin/sed/comments.vim index 4e779d67..53b1524c 100644 --- a/vim/after/ftplugin/sed/comments.vim +++ b/vim/after/ftplugin/sed/comments.vim @@ -1,4 +1,4 @@ -" sed/comments.vim: Set 'comments' for sed +" sed/comments.vim: Set 'comments' and supporting 'formatoptions' for sed " Don't load if running compatible or too old if &compatible || v:version < 700 @@ -6,16 +6,17 @@ if &compatible || v:version < 700 endif " Don't load if already loaded -if exists('b:did_ftplugin_sed_format') +if exists('b:did_ftplugin_sed_comments') finish endif " Flag as loaded -let b:did_ftplugin_sed_format = 1 +let b:did_ftplugin_sed_comments = 1 let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_sed_format' + \ . '|unlet b:did_ftplugin_sed_comments' -" Use trailing whitespace to denote continued paragraph +" Set comment formats setlocal comments=:# +setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' + \ . '|setlocal comments< formatoptions<' diff --git a/vim/after/ftplugin/sh/comments.vim b/vim/after/ftplugin/sh/comments.vim index 247fa2b0..97e8adc9 100644 --- a/vim/after/ftplugin/sh/comments.vim +++ b/vim/after/ftplugin/sh/comments.vim @@ -1,4 +1,4 @@ -" sh/comments.vim: Set 'comments' for shell script +" sh/comments.vim: Set 'comments' and supporting 'formatoptions' for shell script " Don't load if running compatible or too old if &compatible || v:version < 700 @@ -15,7 +15,8 @@ let b:did_ftplugin_sh_comments = 1 let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:did_ftplugin_sh_comments' -" Use trailing whitespace to denote continued paragraph +" Set comment formats setlocal comments=:# +setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' + \ . '|setlocal comments< formatoptions<' -- cgit v1.2.3