1

我使用 (g)Vim 编辑电子邮件,并且我经常需要重排缩进段落中的长行,以>,>>等开头。

例如,想象 mytextwidth设置得很短:

> Line 1 is short.
> Line 2 is very long, really, I mean, far too long, what a mess.
> Line 3 not so.

当我用类似的东西格式化时{gq},它应该变成这样:

> Line 1 is short. Line 2 is very 
> long, really, I mean, far too 
> long, what a mess. Line 3 not so.

我怎样才能让它做到这一点?

4

2 回答 2

2

Vim 对此有内置支持。Vim 有一个选项formatoptions可以让你指定几个这样的东西。检查:h fo-table更多细节。

对于您拥有的特定查询,您可能希望添加,set formatoptions+=q但我希望set formatoptions+=tcroq更好地处理此类格式。

里面还有其他的gem fo-table,我个人用这个设置:set formatoptions=njtcroql

于 2014-06-03T05:08:30.903 回答
1

I used ftplugin to do this:

set comments=fb:*,fb:-,b:>,b:>>,b:>>>,b:>>>>                                    
set autoindent 

The last part of the first line is where the action happens - this provides a "comment block" prefix of >, >>, etc, separated by a blank.

This will only work up the 4th level of indentation, but I could add more if needed.

As an aside, the first two mean I get indented lists easily like this:

* List item is very long, it
  just keeps going and going 
  and going
- And this one uses a dash as
  a bullet point

Edit: as Dhruva Sagar said, the formatoptions will determine whether I can format comments at all with {gq}. The above just says what the comment prefixes are.

于 2014-06-02T18:10:22.673 回答