Automatically continue leading dashes in Haskell comments on wrapping text using Vim

I edit the Haskell source files using Vim and set the "textwidth" option for automatically wrapping superscript lines. So my ~ / .vimrc looks like this:

set tw=78

Now, when I write a line up to 78 characters long, the last word automatically moves to the next line. This is very useful when writing comments in source files. The best part is that in comments, the main comment characters are automatically inserted at the beginning of each line when the last line was too long and was automatically wrapped. But this only works for C-style comments, but unfortunately for Hashell does not exist.

So, for example, in a JS file

/**
 * This is a very long comment which is longer than 78 chars, yeah really 
 * longer than 78 chars...

easily wraps up as well

// This is a very long comment which is longer than 78 chars, yeah really 
// longer than 78 chars...

, , Haskell,

------------------------------------------------------------------------------
-- | This is a very long module description which is longer than 78 chars,
--   yeah really longer than 78 chars...

- , ? ? Does: set formatexpr : set formatoptions ?

!

= < < Johannes

/edit: btw vim 7.3.x

+5
2

vim ( haskell-mode emacs " ", ), , , :

:set comments=:--\ ,sr:{-,m:\ ,ex:-}

-- | , - Haskell :

-- | Bla Bla
--   continues right under the Bla

, :

-- | Usually a one-line short description.
--
-- Continued like this, with a longer description.

, :

-- | Bla bla slightly longer than one line description
-- bla bla.
--
-- Bla bla additional details.

, , :

{-|
The definition of 'myfunc', Act I, Chapter 1. Bla bla bla bla
bla bla...
-}
+2

formatoptions; croql. c , . . :help 'formatoptions'

:set formatoptions=croql
+3

All Articles