2015-10-14 76 views
3

我正在尋找一種在vim中編寫和編輯較長段落的技巧。 本質上,我想要的是vim行爲像html textarea,我目前正在寫這個問題。在vim中對長段落進行方便的換行

在一定程度上,我得到這個行爲,如果我set wrapset linebreak,與j映射到gjk映射到gk。但是,在視覺模式下,運動仍然是線性的,我知道沒有方便的方法來選擇長線的一部分。

此外,我知道textwidth選項自動斷行,如果當前的光標列超過某個閾值。 但是,如果我從中間編輯這條線,當它變得太長時,這條線不會自動中斷。

我也知道我可以使用gq來格式化一組選定的行,但它會在一段時間後變得厭倦。

什麼是在vim中自動換行的技術?

回答

3

如果設置在formatoptions a你可能會得到你whant什麼:

:set formatoptions+=a 

參見:http://vimdoc.sourceforge.net/htmldoc/change.html#auto-format

... 
a Automatic formatting of paragraphs. Every time text is inserted or 
    deleted the paragraph will be reformatted. See |auto-format|. 
    When the 'c' flag is present this only happens for recognized 
    comments. 
... 
+1

完美,謝謝! – lsund