2017-09-06 7 views
0

vimでは、次の段落をgqipを使用してプレーンテキストファイルにフォーマットすると、フォーマッタは列挙型リストのようにインデントします。vimインデント:列挙型リストの推論を無効にする

オリジナル段落:

Here is some text including a number 
3 in the paragraph, which may be 
regarded as the start of a numbered 
list when I format it. 

書式設定(gqip後):問題は、Vimは段落にライン「3かのように "考え" という言葉を揃えることである

Here is some text including a number 
3 in the paragraph, which may be 
    regarded as the start of a numbered 
list when I format it. 

... 「どういうわけか」というパラグラフの「(3)」を意味する。私の意見では、これは書式設定ルールのバグです。普通のテキストで頻繁に発生する明らかな反例があるためです。では、このインデントルールを、リストに似た句読点がある場合にのみ適用するにはどうすればよいですか?たとえば、私はこれがいいと思う:

Here is some text including a number 
3) in the paragraph, which may be 
    regarded as the start of a numbered 
list when I format it. 

このルールにも反対の例がありますが、少なくともエラーはそれほど頻繁に起こりません。ルール、さらにバランスの取れた括弧をチェックして洗練することができ - すなわち:

Here is some text (including a number 
3) in the paragraph, which is not 
regarded as the start of a numbered 
list when I format it (because the 
parenthesis is accounted for by the 
opening parenthesis on line 1). 
+0

は何ですかプレーンテキストファイルのファイルタイプ? – leaf

+0

ファイルの種類はプレーンテキストです。あなたはその拡張部が何であるか尋ねることを意味しますか?ファイル名は "foo.txt"ですが、拡張子が ".tex"のラテックスファイルについても同じ字下げが行われます。 –

+0

':set fo?'の出力は何ですか? – romainl

答えて

1

参照:h fo-tablen文字の意味は、リストのヘッダーをrecogizeするために使用され:h formatlistpatを参照してください。

" 'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*") 

" ignore '3 ' by removing space in pattern 
let &formatlistpat='^\s*\d\+[\]:.)}\t]\s*' 

" ignore (\n3) or [\n3] or {\n3} by adding a preceding NOT match 
let &formatlistpat='\([\[({]\s*\n\)\@<!\_^\s*\d\+[\]:.)}\t]\s*'