LoginSignup
6
1

More than 5 years have passed since last update.

VimでSublimeTextのマルチカーソル(Ctrl+D)っぽいことをする

Last updated at Posted at 2018-02-14

Vimには標準でマルチカーソルモードがなさそう

以下のような外部モジュールを使えば可能
https://github.com/terryma/vim-multiple-cursors

標準機能でそれっぽいことをする


tekisuto
tekisuto
tekisuto

上記をtekisuto→textに変換する。

1./tekisuto でtekisutoを検索
2.先頭のマッチにカーソルが移動したところで cgn とタイプする。
3.自動でその先頭のマッチが消えてInsertモードになる
4.textと入力する。
5.ESCを押す
6.nで次の検索のマッチに移動する。
7.(.)ドットでtekisuto → text の置換を実行する。
8.上記6と7を繰り返す

(参考)もちろん下記のようなコマンドでも単純な置換は実行できます。
:%s/tekisuto/text/g

若干手順が多いですが、慣れれば僕は苦になりませんでした。
ご参考まで。

参考記事

https://blanktar.jp/blog/2015/08/vim-gn-command.html
https://medium.com/@schtoeffel/you-don-t-need-more-than-one-cursor-in-vim-2c44117d51db

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