2011-01-24 33 views
8

在vim的,我可以輸入這樣一行:vim如何讓vim用縮進來包裹帶有項目符號的文本?

- When in the Course of human events it becomes necessary for one people 
    to dissolve the political bands which have connected them with another 
    ... 

,並使其對齊到儀表板右側的vim會自動換行。但是,如果我嘗試這個有星號,這是發生了什麼:

* When in the Course of human events it becomes necessary for one people 
to dissolve the political bands which have connected them with another ... 

有沒有一種方法,使與領先的星號的自動縮進工作,它爲主導的儀表板以同樣的方式?

+0

你使用什麼文件類型來獲得與短劃線的縮進?答案可能被埋在那個語法文件中。 – Jay 2011-01-24 14:31:37

回答

9

這是使用comments設置完成的(請參閱:help 'comments':help format-comments)。

您需要添加的設置是fb:*,它說,存在與*開始和*必須跟一個空白,只是在註釋的第一行的註釋類型。 Vim處理其餘部分。但是,請注意,默認設置包括*作爲多行C註釋的中間,因此您需要禁用此選項。

如果連字符前綴和星號爲前綴的線是你要喜歡這個工作唯一的,這樣做:

set comments=fb:-,fb:* 

另外,隨你喜歡調整默認評論設置::set comments?顯示當前設置和:help format-comments解釋它是什麼意思。

如果你想這是特定文件類型,創建~/.vim/ftplugin(或vimfiles在Windows上)與文件名作爲extension.vim(例如txt.vim.txt文件)的文件。在這個文件中放:

setlocal comments=fb:-,fb:* 

這將配置comments設置了相關的文件類型,而不影響其它文件。