When I turn on autoindent
for a regular *.hs file, the after pressing Enter the new line is indented as expected. However, this doesn't work with literate Haskell *.lhs files whose code lines start with >
(AKA "bird-tracks"). The cursor is always positioned at the first column.
How can I set up vim so that when I'm inside a piece of code in a *.lhs file (and let\s say have autoindent
on), pressing Enter creates a bird track at the new line and indents appropriately?
Update: To give an example, let's say have
> myfn x | x <= 0 = 0
> | x == 1 = 1▌
where ▌
represents the position of the cursor (I hope you have no problem seeing the unicode character.) If I press Enter, I end up with
> myfn x | x <= 0 = 0
> | x == 1 = 1
▌
whereas I want
> myfn x | x <= 0 = 0
> | x == 1 = 1
> ▌
This should be easy to achieve with
or
:se fo+=ro
for short.With
r
ando
in'formatoptions'
, Vim attempts to insert the comment "leader" including indentation on new lines inside a comment (that is, a non-comment in literate Haskell).To make this setting automatically, set up an autocommand in your vimrc.
Tip: Use
CTRL-U
to remove the auto-inserted leader when you don't need it.