LoginSignup
7
7

More than 5 years have passed since last update.

今日のvim: ちょっとだけ手数の少ない置換

Posted at

お題

文字列を置換したい。
いつもの

:%s/before/after/g

の応用です。

やりかた

examplehogefoobar に置換したい。

web0.example.com
web1.example.com
web2.example.com
web3.example.com
web4.example.com
web5.example.com
web6.example.com
web7.example.com
web8.example.com
web9.example.com

置換したい文字列上(今回は example)にカーソルをのせた状態で

*:%s//hogefoobar/g

で、ターン。

web0.hogefoobar.com
web1.hogefoobar.com
web2.hogefoobar.com
web3.hogefoobar.com
web4.hogefoobar.com
web5.hogefoobar.com
web6.hogefoobar.com
web7.hogefoobar.com
web8.hogefoobar.com
web9.hogefoobar.com

ポイントは * で検索した文字が自動的に before のところに入ってるって(とこ。|、ことなのか?)

7
7
0

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