Add A
, I
, $
, 0
bindings to iedit state
This commit is contained in:
parent
b344553aaf
commit
8461b0a421
|
@ -7,10 +7,9 @@
|
||||||
- [Install](#install)
|
- [Install](#install)
|
||||||
- [Key bindings](#key-bindings)
|
- [Key bindings](#key-bindings)
|
||||||
- [State transitions](#state-transitions)
|
- [State transitions](#state-transitions)
|
||||||
- [In `iedit state`](#in-iedit-state)
|
- [In iedit state](#in-iedit-state)
|
||||||
- [In `iedit-insert state`](#in-iedit-insert-state)
|
- [In iedit-insert state](#in-iedit-insert-state)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Tips](#tips)
|
|
||||||
|
|
||||||
<!-- markdown-toc end -->
|
<!-- markdown-toc end -->
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ or <kbd>fd</kbd> to return to `normal state`.
|
||||||
**Note:** evil commands which switch to `insert state` will switch in
|
**Note:** evil commands which switch to `insert state` will switch in
|
||||||
`iedit-insert state`.
|
`iedit-insert state`.
|
||||||
|
|
||||||
### In `iedit state`
|
### In iedit state
|
||||||
|
|
||||||
`iedit state` inherits from `normal state`, the following key bindings are
|
`iedit state` inherits from `normal state`, the following key bindings are
|
||||||
specific to `iedit state`.
|
specific to `iedit state`.
|
||||||
|
@ -66,12 +65,15 @@ specific to `iedit state`.
|
||||||
Key Binding | Description
|
Key Binding | Description
|
||||||
------------------|------------------------------------------------------------
|
------------------|------------------------------------------------------------
|
||||||
<kbd>ESC</kbd> | go back to `normal state`
|
<kbd>ESC</kbd> | go back to `normal state`
|
||||||
|
<kbd>0</kbd> | go to then beginning of the current occurrence
|
||||||
|
<kbd>$</kbd> | go to then end of the current occurrence
|
||||||
<kbd>#</kbd> | prefix all occurrences with an increasing number (<kbd>SPC u</kbd> to choose the starting number).
|
<kbd>#</kbd> | prefix all occurrences with an increasing number (<kbd>SPC u</kbd> to choose the starting number).
|
||||||
|
<kbd>A</kbd> | go to the beginning of the current occurrence and switch to `iedit-insert state`
|
||||||
<kbd>D</kbd> | delete the occurrences
|
<kbd>D</kbd> | delete the occurrences
|
||||||
<kbd>F</kbd> | restrict the scope to the function
|
<kbd>F</kbd> | restrict the scope to the function
|
||||||
<kbd>gg</kbd> | go to first occurrence
|
<kbd>gg</kbd> | go to first occurrence
|
||||||
<kbd>G</kbd> | go to last occurrence
|
<kbd>G</kbd> | go to last occurrence
|
||||||
<kbd>I</kbd> | toggle case-sensitivity
|
<kbd>I</kbd> | go to the end of the current occurrence and switch to `iedit-insert state`
|
||||||
<kbd>J</kbd> | increase the edition scope by one line below
|
<kbd>J</kbd> | increase the edition scope by one line below
|
||||||
<kbd>K</kbd> | increase the edition scope by one line above
|
<kbd>K</kbd> | increase the edition scope by one line above
|
||||||
<kbd>L</kbd> | restrict the scope to the current line
|
<kbd>L</kbd> | restrict the scope to the current line
|
||||||
|
@ -83,7 +85,7 @@ specific to `iedit state`.
|
||||||
<kbd>U</kbd> | Up-case the occurrences
|
<kbd>U</kbd> | Up-case the occurrences
|
||||||
<kbd>C-U</kbd> | down-case the occurrences
|
<kbd>C-U</kbd> | down-case the occurrences
|
||||||
|
|
||||||
### In `iedit-insert state`
|
### In iedit-insert state
|
||||||
|
|
||||||
Key Binding | Description
|
Key Binding | Description
|
||||||
---------------------------|------------------------------------------------------------
|
---------------------------|------------------------------------------------------------
|
||||||
|
@ -97,13 +99,6 @@ specific to `iedit state`.
|
||||||
- substitute symbol _with expand-region_: <kbd>SPC v v e S "toto" ESC ESC</kbd>
|
- substitute symbol _with expand-region_: <kbd>SPC v v e S "toto" ESC ESC</kbd>
|
||||||
- replace symbol with yanked (copied) text _with expand region_: <kbd>SPC v e p ESC ESC</kbd>
|
- replace symbol with yanked (copied) text _with expand region_: <kbd>SPC v e p ESC ESC</kbd>
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
- Make `A` append to the end of the edited region.
|
|
||||||
- Make `I` insert to the beginning of the edited region.
|
|
||||||
- Make `0` go to the beginning of the edited region.
|
|
||||||
- Make `$` go to the end of the edited region.
|
|
||||||
|
|
||||||
[auto-highlight-symbol]: https://github.com/gennad/auto-highlight-symbol
|
[auto-highlight-symbol]: https://github.com/gennad/auto-highlight-symbol
|
||||||
[iedit]: https://github.com/tsdh/iedit
|
[iedit]: https://github.com/tsdh/iedit
|
||||||
[expand-region]: https://github.com/magnars/expand-region.el
|
[expand-region]: https://github.com/magnars/expand-region.el
|
||||||
|
|
|
@ -30,13 +30,49 @@
|
||||||
(iedit-done)
|
(iedit-done)
|
||||||
(evil-normal-state))
|
(evil-normal-state))
|
||||||
|
|
||||||
(defmacro evil-iedit-state|wrap-evil-command (command)
|
(defmacro evil-iedit-state||swith-to-insert-state-after-command (command &optional interactive)
|
||||||
"Call evil command and switch to iedit-insert state."
|
"Call COMMAND and switch to iedit-insert state.
|
||||||
|
If INTERACTIVE is non-nil then COMMAND is called interactively."
|
||||||
`(progn
|
`(progn
|
||||||
|
(if ,interactive
|
||||||
(call-interactively ',command)
|
(call-interactively ',command)
|
||||||
(evil-iedit-state) ; required to correctly update the cursors
|
(funcall ',command))
|
||||||
|
;; required to correctly update the cursors
|
||||||
|
(evil-iedit-state)
|
||||||
(evil-iedit-insert-state)))
|
(evil-iedit-insert-state)))
|
||||||
|
|
||||||
|
(defun evil-iedit-state//goto-overlay-start ()
|
||||||
|
"Return the position of the start of the current overlay."
|
||||||
|
(goto-char (overlay-start (iedit-find-current-occurrence-overlay))))
|
||||||
|
|
||||||
|
(defun evil-iedit-state//goto-overlay-end ()
|
||||||
|
"Return the position of the end of the current overlay."
|
||||||
|
(goto-char (overlay-end (iedit-find-current-occurrence-overlay))))
|
||||||
|
|
||||||
|
(defun evil-iedit-state/evil-beginning-of-line (count)
|
||||||
|
"Go to the beginning of the current overlay."
|
||||||
|
(interactive "p")
|
||||||
|
(evil-iedit-state//goto-overlay-start))
|
||||||
|
|
||||||
|
(defun evil-iedit-state/evil-end-of-line ()
|
||||||
|
"Go to the beginning of the current overlay."
|
||||||
|
(interactive)
|
||||||
|
(evil-iedit-state//goto-overlay-end))
|
||||||
|
|
||||||
|
(defun evil-iedit-state/evil-append-line ()
|
||||||
|
"Put the point at then end of current overlay and switch to
|
||||||
|
`iedit-insert state'."
|
||||||
|
(interactive)
|
||||||
|
(evil-iedit-state||swith-to-insert-state-after-command
|
||||||
|
evil-iedit-state//goto-overlay-end))
|
||||||
|
|
||||||
|
(defun evil-iedit-state/evil-insert-line ()
|
||||||
|
"Put the point at then end of current overlay and switch to
|
||||||
|
`iedit-insert state'."
|
||||||
|
(interactive)
|
||||||
|
(evil-iedit-state||swith-to-insert-state-after-command
|
||||||
|
evil-iedit-state//goto-overlay-start))
|
||||||
|
|
||||||
(defun evil-iedit-state/substitute ()
|
(defun evil-iedit-state/substitute ()
|
||||||
"Wipe all the occurrences and switch in `iedit-insert state'"
|
"Wipe all the occurrences and switch in `iedit-insert state'"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -46,7 +82,7 @@
|
||||||
(defun evil-iedit-state/evil-change ()
|
(defun evil-iedit-state/evil-change ()
|
||||||
"Wipe all the occurrences and switch in `iedit-insert state'"
|
"Wipe all the occurrences and switch in `iedit-insert state'"
|
||||||
(interactive)
|
(interactive)
|
||||||
(evil-iedit-state|wrap-evil-command evil-change))
|
(evil-iedit-state||swith-to-insert-state-after-command evil-change t))
|
||||||
|
|
||||||
(defun evil-iedit-state/paste-replace (count)
|
(defun evil-iedit-state/paste-replace (count)
|
||||||
"Replace the selection with the yanked text."
|
"Replace the selection with the yanked text."
|
||||||
|
@ -57,12 +93,12 @@
|
||||||
(defun evil-iedit-state/evil-append ()
|
(defun evil-iedit-state/evil-append ()
|
||||||
"Append and switch to `iedit-insert state'"
|
"Append and switch to `iedit-insert state'"
|
||||||
(interactive)
|
(interactive)
|
||||||
(evil-iedit-state|wrap-evil-command evil-append))
|
(evil-iedit-state||swith-to-insert-state-after-command evil-append t))
|
||||||
|
|
||||||
(defun evil-iedit-state/evil-substitute ()
|
(defun evil-iedit-state/evil-substitute ()
|
||||||
"Append and switch to `iedit-insert state'"
|
"Append and switch to `iedit-insert state'"
|
||||||
(interactive)
|
(interactive)
|
||||||
(evil-iedit-state|wrap-evil-command evil-substitute))
|
(evil-iedit-state||swith-to-insert-state-after-command evil-substitute t))
|
||||||
|
|
||||||
;; expand-region integration, add an "e" command
|
;; expand-region integration, add an "e" command
|
||||||
(eval-after-load 'expand-region
|
(eval-after-load 'expand-region
|
||||||
|
@ -112,14 +148,17 @@ the initial string globally."
|
||||||
(run-hooks 'iedit-mode-end-hook))
|
(run-hooks 'iedit-mode-end-hook))
|
||||||
|
|
||||||
(define-key evil-iedit-state-map "#" 'iedit-number-occurrences)
|
(define-key evil-iedit-state-map "#" 'iedit-number-occurrences)
|
||||||
|
(define-key evil-iedit-state-map "$" 'evil-iedit-state/evil-end-of-line)
|
||||||
|
(evil-redirect-digit-argument evil-iedit-state-map "0" 'evil-iedit-state/evil-beginning-of-line)
|
||||||
(define-key evil-iedit-state-map "a" 'evil-iedit-state/evil-append)
|
(define-key evil-iedit-state-map "a" 'evil-iedit-state/evil-append)
|
||||||
|
(define-key evil-iedit-state-map "A" 'evil-iedit-state/evil-append-line)
|
||||||
(define-key evil-iedit-state-map "c" 'evil-iedit-state/evil-change)
|
(define-key evil-iedit-state-map "c" 'evil-iedit-state/evil-change)
|
||||||
(define-key evil-iedit-state-map "D" 'iedit-delete-occurrences)
|
(define-key evil-iedit-state-map "D" 'iedit-delete-occurrences)
|
||||||
(define-key evil-iedit-state-map "F" 'iedit-restrict-function)
|
(define-key evil-iedit-state-map "F" 'iedit-restrict-function)
|
||||||
(define-key evil-iedit-state-map "gg" 'iedit-goto-first-occurrence)
|
(define-key evil-iedit-state-map "gg" 'iedit-goto-first-occurrence)
|
||||||
(define-key evil-iedit-state-map "G" 'iedit-goto-last-occurrence)
|
(define-key evil-iedit-state-map "G" 'iedit-goto-last-occurrence)
|
||||||
(define-key evil-iedit-state-map "i" 'evil-iedit-insert-state)
|
(define-key evil-iedit-state-map "i" 'evil-iedit-insert-state)
|
||||||
(define-key evil-iedit-state-map "I" 'iedit-toggle-case-sensitive)
|
(define-key evil-iedit-state-map "I" 'evil-iedit-state/evil-insert-line)
|
||||||
(define-key evil-iedit-state-map "J" 'iedit-expand-down-a-line)
|
(define-key evil-iedit-state-map "J" 'iedit-expand-down-a-line)
|
||||||
(define-key evil-iedit-state-map "K" 'iedit-expand-up-a-line)
|
(define-key evil-iedit-state-map "K" 'iedit-expand-up-a-line)
|
||||||
(define-key evil-iedit-state-map "L" 'iedit-restrict-current-line)
|
(define-key evil-iedit-state-map "L" 'iedit-restrict-current-line)
|
||||||
|
@ -138,4 +177,8 @@ the initial string globally."
|
||||||
(define-key evil-iedit-insert-state-map "\C-g" 'evil-iedit-state/quit-iedit-mode)
|
(define-key evil-iedit-insert-state-map "\C-g" 'evil-iedit-state/quit-iedit-mode)
|
||||||
(define-key evil-iedit-insert-state-map [escape] 'evil-iedit-state)
|
(define-key evil-iedit-insert-state-map [escape] 'evil-iedit-state)
|
||||||
|
|
||||||
|
;; unbound iedit commands:
|
||||||
|
;; toggle buffering
|
||||||
|
;; toggle case sensitive
|
||||||
|
|
||||||
(provide 'evil-iedit-state)
|
(provide 'evil-iedit-state)
|
||||||
|
|
Loading…
Reference in a new issue