LoginSignup
48
47

More than 3 years have passed since last update.

空行の削除

Last updated at Posted at 2014-06-21

TL;DR

:v/./dを実行。

概要

空白行を消したいとき、vimなら簡単にできます。

パターン1

  1. :%s/\s*$で、末尾の空白を削除。
  2. :v/./dを実行。

末尾の空白がない場合は、:v/./dだけでなのでおすすめです。

なにより、/./が打ちやすい。

パターン2

:v/\S/dを実行。

/\が打ちにくいので、私はあまり使わない。

a
{空白行}
b
{空白行}
c
{空白行}
d

a
b
c
d

まとめてファイルを編集したい場合

:argdo %v/./d | update
48
47
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
48
47