LoginSignup
128
112

More than 5 years have passed since last update.

VIMで選択行をソートする

Last updated at Posted at 2012-08-14

<S-V> で行選択した状態で、以下のコマンドを実行すれば昇順にソートされます。

:sort

vimの内部コマンドにsortがあったのね。初めて知りました。

以下のように、外部コマンドの sort.exe を使ってソートすると、文字化けすることがあるので上記の内部コマンドを使いましょう。

:!sort

2012/08/14 補足

内部コマンドsortのヘルプを以下のコマンドで参照すると、色々なオプションがありますね。

:h :sort

逆順でソート

:sort!

重複行を削除(uniq)

:sort u

最初に見つかる数字でソート(10進数)

:sort n

正規表現にマッチする部分でソート

:sort /\a\a\a/ r
128
112
2

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
128
112