回答:
これはformatoptions設定で制御されます。から:help fo-table:
この
'formatoptions'オプションを使用して、Vimがテキストをフォーマットする方法に影響を与えることができます。'formatoptions'以下の文字を含むことができる文字列です。デフォルト設定はtcqです。読みやすくするために、オプション文字をコンマで区切ることができます。
多くのファイルタイプはフォーマットオプションをファイルタイプに最適に変更するため、「デフォルト」に関する記述はやや誤解を招くことに注意してください。例えば/usr/share/vim/vim74/ftplugin/vim.vim:
" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
setlocal fo-=t fo+=croql
次の方法で現在formatoptionsを表示できます。
:set fo?
formatoptions=jcroql
そして、それらが次のように設定されている場所を確認します。
:verbose set fo?
formatoptions=jcroql
Last set from /usr/share/vim/vim74/ftplugin/vim.vim
この場合は、削除したいrフラグを、おそらくもcとoのフラグ:
r Automatically insert the current comment leader after hitting
<Enter> in Insert mode.
c Auto-wrap comments using textwidth, inserting the current comment
leader automatically.
o Automatically insert the current comment leader after hitting 'o' or
'O' in Normal mode.
これは次のように実行できます。
:set formatoptions-=r formatoptions-=c formatoptions-=o
を使用:set formatoptions-=croすると、期待どおりに機能しないことに注意してください(文字列croであるため、この順序でstringを検索しますが、多くの場合は機能しません)。
現在のバッファのみに変更を設定する:setlocalには、の代わりに使用します:set。これらのオプションを常に使用したい場合autocmdは、vimrcでを使用するのがおそらく最善です。例えば:
au FileType vim setlocal fo-=c fo-=r fo-=o
これにより、「vim」ファイルタイプのみにオプションが設定され、他のファイルタイプに干渉しません。
あなたがしたい場合は、常にそれを設定し、使用:
au FileType * set fo-=c fo-=r fo-=o
set fo-=cro多くのファイルタイプが設定/拡張されるためformatoption(上記のように)、使用するだけでは機能しません。Filetype autocmdは、filetypeファイルが読み込まれた後に実行されます。
au FileType * set fo-=o.vimrcに追加しても機能しませんでした。oコメント付きの行を押しても、まだコメントされています。
formatoptionsは、txtファイルがラップされていました。私は頭を振り回しtextwidthてwrapmarginいましたが、何も機能しませんでした。バグだと思って、vimを8.1から8.0にダウングレードしました。これで私の問題は解決しました、ありがとう。
これをvimrcに追加します。
au BufEnter * set fo-=c fo-=r fo-=o
FileType他のプラグインが設定されているため、使用は機能しませんformatoption。