12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

正規表現に自信が無い人も安心 visual-regexp.el

Posted at

正規表現にイマイチ自身が無くて、文字列置換などで活用できてない。

そんな時には visial-regexp.el を使おう。

visual-regexp.el 公式

準備

load-path の通った所に glone してくる

$ cd load-path-dir
$ git clone https://github.com/benma/visual-regexp.el.git

設定

公式のままw

(require 'visual-regexp)
(define-key global-map (kbd "C-c r") 'vr/replace)
(define-key global-map (kbd "C-c q") 'vr/query-replace)
(define-key global-map (kbd "C-c m") 'vr/mc-mark)

使い方

設定したキーバインドでってのは当たり前だが、まずは vr/query-replace を試すと、
何となくこんなものってのが掴めるはず。

正規表現にマッチした箇所がハイライトされるので、納得できる所で RET
置換後の文字列も => の後ろに入力内容通りに表示される。
query-replace 同様に y なら置換、 n ならそのままで次の候補に移動。

これで、 replace-regexp が使いこなせなくても、大丈夫になるはず。

正規表現で会話できる系の人は、 replace-regexp で頑張ってください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?