How to use expand-region.el in Emacs efficiently
expand-region.el is very useful. I use it to select a code segment and keep press its expand key until the the desired region is selected.
The only issue is its recommended hotkey for "er/expand-region" is "C-=". A little bit hard to press.
After marking a region by pressing "C-
", I press "" to expand the region and "-" to contract.
As you may have noticed, I need move the right hand to press "=" or "-" so it's not quick enough.
The solution is simple, press ",xx" to select the initial region. Keep press "x" to expand. "z" to contract region because "x" "z" is close to left hand fingers.
evil-mode and evil-leader is required to implement this.
Here is the setup:
(require 'evil) (require 'evil-leader) (evil-mode 1) ;; enable evil-mode (with-eval-after-load 'evil (setq expand-region-contract-fast-key "z")) (evil-leader/set-key "xx" 'er/expand-region)