git clone 'git://github.com/benma/visual-regexp-steroids.el.git'
visual-regexp-steroids is an extension to visual-regexp which enables the use of modern regexp engines (no more escaped group parentheses, and other goodies!).
In addition to that, you can optionally use the better regexp syntax to power
For now, Python and pcre2el is supported out of the box (tested on Linux and Windows). If you want to add custom scripts to enable your favorite language, please get in touch.
Requirements: * visual-regexp * Python
If you are using Emacs 24, you can get visual-regexp-steroids from melpa with the package manager.
Add the following code to your init file. Of course you can select your own key bindings.
vr/mc-mark is an interface to multiple-cursors.
The functions are the same as in visual-regexp, but powered by Python (or another custom engine).
You can choose the engine (e.g. to fall back to the Emacs regexp engine) with
;; if the files are not already in the load path (add-to-list 'load-path "folder-to/visual-regexp/") (add-to-list 'load-path "folder-to/visual-regexp-steroids/") (require 'visual-regexp-steroids) (define-key global-map (kbd "C-c r") 'vr/replace) (define-key global-map (kbd "C-c q") 'vr/query-replace) ;; if you use multiple-cursors, this is for you: (define-key global-map (kbd "C-c m") 'vr/mc-mark) ;; to use visual-regexp-steroids's isearch instead of the built-in regexp isearch, also include the following lines: (define-key esc-map (kbd "C-r") 'vr/isearch-backward) ;; C-M-r (define-key esc-map (kbd "C-s") 'vr/isearch-forward) ;; C-M-s
To customize, use
M-x customize-group [RET] visual-regexp. You can specify which engine to use by modifying
vr/engine (defaults to Python), and how the Python interpreter is invoked by modifying the
vr/command-python variable. The default is
Same example as in visual-regexp, but this time using Python's regular expressions (note the absence of escape characters):
visual-regexp-steroids also features expressions as replacements (toggle with
Expressions have a predefined variables.
i, the match counter, is one of them:
If you found this useful, please consider donating.