I have a Haskell file on VIM with a Haskell-style comment block:


When I select that comment block on visual mode...


And press gq, I expected VIM to format my comment to something like:


But instead, this is what VIM does:


How can I fix it?

  • 2
    It works on my gVim (version 7.4-798). What's the result of running :set ft? and :set comments?. What's your Vim version? Do you have :filetype plugin indent on in your vimrc ?
    – VanLaser
    Commented Aug 10, 2015 at 19:09
  • I don't have that, VanLaser. I actually have "filetype plugin on commented, I recall actively doing so for some reason I don't remember. set ft? gives haskell, and set comments gives comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- (before Lithis's answer).
    – MaiaVictor
    Commented Aug 10, 2015 at 19:13
  • Yes, no wonder the comments aren't recognized ... :)
    – VanLaser
    Commented Aug 10, 2015 at 19:16
  • 2
    Okay I see the filetype plugin is what VIM uses for filetype based comments.
    – MaiaVictor
    Commented Aug 10, 2015 at 19:22

1 Answer 1


:set comments+=:--

This appends :-- to the value of comments, which adds -- as a comment line indicator. The format of this option is described by :help format-comments.

  • 2
    The question is, I guess, why isn't it already there, in OP case?
    – VanLaser
    Commented Aug 10, 2015 at 19:09
  • @VanLaser I don't know, maybe my vimrc or existing plugins messed with it (if it was supposed to?) It solves the issue, though. Thank you all!
    – MaiaVictor
    Commented Aug 10, 2015 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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