2014-02-13 30 views
11

我正在VIM中編寫一個項目符號列表,並設置了textwidth = 79來硬包裝線條。當我寫清單時,我希望每個回車都能生成一個新的子彈,並且包裹的線條不會有子彈。但是,VIM正在做相反的事情(包裝線上的子彈,回車後沒有子彈)。我想:Vim:不帶前導字符的Textwrap

* Item 1 - The text for this line is too long and 
    so is wrapped to the next line. 
* Item 2 - Typing a carriage return after item 1 
    should produce the bullet for this item. 

然而,VIM做到這一點:

* Item 1 - The text for this line is too long and 
* so is wrapped to the next line. 
Item 2 - Typing a carriage return after item 1 
should produce the bullet for this line. 

我已經自動縮進上,cindent關閉,formatexpr是一個空字符串。我理解並喜歡C樣式註釋的自動插入'*'行爲,但會喜歡文本文件類型的不同行爲。有沒有允許這個設置?

+0

您可以使用'gq'來格式化文本(這是我通常所做的),但它似乎只適用於'-'(而不適用於'*') – Carpetsmoker

+0

我已經能夠漂亮關閉設置「comments = fb:*」和「formatoptions = tcq」。這包裝正確,但不會在回車後添加子彈。我認爲向格式選項添加'r'聽起來應該是這樣,但似乎並非如此。 – FazJaxton

+0

我認爲你用':set fo + = r comments = fb:*'得到你想要的一半。 – benjifisher

回答

1

嘗試

set formatoptions=tn autoindent 
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-]\s\)\s*' 

ñ標誌formatoptions觸發你,但formatlistpat的默認設置只處理編號列表後列表的格式。上面的一個添加了*-的子彈。