3

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

http://i.stack.imgur.com/5uKS2.png

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

http://i.stack.imgur.com/TFHWf.png

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

http://i.stack.imgur.com/4nsgT.png

But instead, this is what VIM does:

http://i.stack.imgur.com/qn2Dw.png

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 Aug 10 '15 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 Aug 10 '15 at 19:13
  • Yes, no wonder the comments aren't recognized ... :) – VanLaser Aug 10 '15 at 19:16
  • 2
    Okay I see the filetype plugin is what VIM uses for filetype based comments. – MaiaVictor Aug 10 '15 at 19:22
6

: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 Aug 10 '15 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 Aug 10 '15 at 19:11

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.