I am editing a HTML document (filetype=html) in vim. foldmarker is set to {,}, foldmethod to marker and commentstring to <!--%s-->.

When I visually select a region and use zf to create a folding, vim inserts a { at the beginning and a } at the end of the region. However, with my settings, I expected vim to insert <!--{--> and <!--}-->, respectively.

Why is vim ignoring commentstring when folding?

  • It works for XML, but doesn't work for HTML, indeed. But if you setlocal comments= then it will work.
    – Maxim Kim
    Dec 6 '18 at 15:45
  • cannot reproduce. Please try to come up with a minimal example starting with vim --clean Dec 6 '18 at 16:05
  • Sh, it seems to be caused by the n:> flag of the 'comments' option, however, that is not included in the html filetype (so it happens, if you manually override it afterwards). Please check where you set this Dec 6 '18 at 16:13
  • @ChristianBrabandt I can reproduce it with comments=s:<!--,m: ,e:--> which is set by html filetype.
    – Maxim Kim
    Dec 6 '18 at 16:22
  • @ChristianBrabandt and it happens when you try to do it on a paragraph for example, but don't start and end on empty lines. Just do zfip.
    – Maxim Kim
    Dec 6 '18 at 16:24

This answer probably should be deleted. Answering here to show it @ChristianBrabandt.

It is kind of strange but for some text it works, for the other it doesn't:

enter image description here

And if you change the first paragraph to:

blablabla a

Then it will not work for the first row. Looks like if there are more than 1 word on the line it doesn't insert commentstring.

vim version:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec  5 2018 23:02:23)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-565
Compiled by appveyor@APPVYR-WIN
Huge version with GUI.  Features included (+) or not (-):
+acl                +comments           +file_in_path       +listcmds           +persistent_undo    +tag_binary         +visualextra
+arabic             +conceal            +find_in_path       +localmap           -postscript         +tag_old_static     +viminfo
+autocmd            +cryptv             +float              +lua/dyn            +printer            -tag_any_white      +vreplace
+autochdir          +cscope             +folding            +menu               +profile            +tcl/dyn            -vtp
+autoservername     +cursorbind         -footer             +mksession          +python/dyn         -termguicolors      +wildignore
+balloon_eval       +cursorshape        +gettext/dyn        +modify_fname       +python3/dyn        +terminal           +wildmenu
-balloon_eval_term  +dialog_con_gui     -hangul_input       +mouse              +quickfix           -tgetent            +windows
+browse             +diff               +iconv/dyn          +mouseshape         +reltime            -termresponse       +writebackup
++builtin_terms     +digraphs           +insert_expand      +multi_byte_ime/dyn +rightleft          +textobjects        -xfontset
+byte_offset        +directx            +job                +multi_lang         +ruby/dyn           +timers             -xim
+channel            -dnd                +jumplist           +mzscheme/dyn       +scrollbind         +title              +xpm_w32
+cindent            -ebcdic             +keymap             +netbeans_intg      +signs              +toolbar            -xterm_save
+clientserver       +emacs_tags         +lambda             +num64              +smartindent        +user_commands      
+clipboard          +eval               +langmap            +ole                +startuptime        +vartabs            
+cmdline_compl      +ex_extra           +libcall            +packages           +statusline         +vertsplit          
+cmdline_hist       +extra_search       +linebreak          +path_extra         -sun_workshop       +virtualedit        
+cmdline_info       +farsi              +lispindent         +perl/dyn           +syntax             +visual             
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
    system menu file: "$VIMRUNTIME\menu.vim"
Linking: link  /nologo /subsystem:windows,5.02 /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:AMD64  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   "C:\Tcl\lib\tclstub86.lib" WSock32.lib xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug
  • Looks like a bug to me and seems to be caused by v8.0.0453 if my short testing was correct. Can someone create an issue for that? Dec 6 '18 at 17:09
  • github.com/vim/vim/issues/3670 @ChristianBrabandt could you step in and comment there about vim version caused the issue?
    – Maxim Kim
    Dec 6 '18 at 17:19
  • should be fixed now Dec 9 '18 at 18:47
  • @ChristianBrabandt, yes I have checked it with the new build -- it is fixed.
    – Maxim Kim
    Dec 9 '18 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.