Vim - ドットの後のスペースを改行文字に置き換える方法は?

Vim - ドットの後のスペースを改行文字に置き換える方法は?

Webの一部のテキストをVimエディタに貼り付けましたが、何らかの理由で各段落が1行に処理されます。

PROD $ egrep -i 'system' text
Hurricane Dorian is a strong tropical cyclone currently affecting the Bahamas and the Southeastern United States. The fourth named storm, second hurricane, and first major hurricane of the 2019 Atlantic hurricane season, Dorian developed from a tropical wave on August 24 in the Central Atlantic. The system gradually intensified while moving toward the Lesser Antilles, before becoming a hurricane on August 28. Rapid intensification ensued, and on August 31, Dorian intensified into a Category 4 major hurricane. On the following day, Dorian reached Category 5 intensity, peaking with one-minute sustained winds of 185 mph (295 km/h) and a minimum central pressure of 910 millibars (26.87 inHg) while making landfall in Elbow Cay, Bahamas, at 16:40 UTC. Dorian made another landfall on Grand Bahama several hours later, near the same intensity.

各文が1行で処理されるように貼り付けたテキストの形式を再指定したいと思います。また、文章の最後に「.」を保ちたいです。 Vimでどうすればいいですか?それとも、貼り付けた段落が最初に1行で処理されるのを防ぐ方法は何ですか?

:%s/. /\n/g動作しません。動作していても、ドットとスペースを改行文字に置き換えますが、各文の末尾にドットを保持したいと思います。

ありがとう

ベストアンサー1

:%s/. /\n/gほぼ似ていますが、3つのエラーがあります。

  • .すべての文字と一致します。実際のポイントを一致させるにはエスケープしてください。\.
  • 点を保持するには、代替文字列に入れます(やや明らかです)
  • \nヌル文字です。\r改行文字の場合

その結果は次のとおりです。

:%s/\. /.\r/g

おすすめ記事