How to configure vim authentication for proper Haskell programming?

When I turn on autoindent for a regular * .hs file, after pressing Enter, the new line is indented as expected. However, this does not work with literate Haskell * .lhs files whose lines of code begin with > (AKA "bird-tracks"). The cursor is always in the first column.

How to configure vim so that when I am inside a piece of code in a * .lhs file (and let \ s say that it has autoindent ), pressing Enter creates a track with a bird on a new line and indents accordingly?

Update: To give an example, let's say

 > myfn x | x <= 0 = 0 > | x == 1 = 1β–Œ 

where β–Œ denotes the cursor position (I hope you have no problem viewing the Unicode character.) If I press Enter, I end up

 > myfn x | x <= 0 = 0 > | x == 1 = 1 β–Œ 

then how i want

 > myfn x | x <= 0 = 0 > | x == 1 = 1 > β–Œ 
+4
source share
1 answer

This is easy to achieve with

 :set formatoptions+=ro 

or :se fo+=ro for short.

With r and o in 'formatoptions' , Vim tries to insert a β€œleader” comment, including indentation on new lines inside the comment (i.e. not a comment in literate Haskell).

To make this parameter automatically, configure the auto command in your vimrc.

 autocmd FileType lhaskell setlocal formatoptions+=ro 

Tip. Use CTRL-U to remove the automatically inserted leader when you do not need it.

+6
source

Source: https://habr.com/ru/post/1500103/


All Articles