Created
April 5, 2010 14:28
-
-
Save koki-h/356395 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# vim で、特定ファイル全部を、確認しながら置換する | |
# http://subtech.g.hatena.ne.jp/cho45/20100405/1270444967 | |
# をシェルスクリプトにしてみた。 | |
# $ replace-confirn /Foo/Bar/ *.txt のようにして使う。 | |
# (変な引数を渡すと当然変な結果になるので注意) | |
# コマンドが起動するとvimが開き、パターンにマッチする部分がハイライト表示されるので | |
# そのまま置換するときはy、置換せずに次のマッチに飛ぶときはnをタイプする。 | |
# すべてのファイルを表示し終わると普通のvimのコマンドモードになるので:qをタイプして終了する。 | |
pattern=$1 | |
shift | |
files=$* | |
vim -c "silent! argdo %s${pattern}gc | update" ${files} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment