LoginSignup
3
3

More than 5 years have passed since last update.

< Vim > 全てのテキスト、ファイルディレクトリ名を置換

Last updated at Posted at 2014-11-11

ファイル内テキストの置換

:argadd **/*
:argdo %s/old/new/gc

g ・・・ 全体指定
c ・・・ 確認

これを実行した際、writeされていなかったので
下記を実行して全ファイル上書きした。

:bufdo w

または、

:bufdo %s/old/new/g | w

推奨

下記コマンドで変更があったファイルのみ上書きされる ( Layzie様よりご指摘頂きました ) 。

:argdo %s/old/new/gc | up

ディレクトリ名、ファイル名の置換

\find . -name *old* | vim -

:%s/.*/\="mv -i ".submatch(0)." ".substitute(submatch(0), "old", "new", "g")/g

:w !sh

詳しくはこちら

注意: .git/ も入ってるので削除してから:w !shをしないと大変なことなります。

備考

cオプションをつけたか分からないが、下記のように出た際、矢印キーを下かenter押し続けないと進まなかった・・・
-- More --

3
3
3

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
3
3