Skip to content

Commit

Permalink
Merge branch 'develop' (v0.26.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Dec 7, 2014
2 parents 1958678 + 482afcb commit 5fb8a50
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
12 changes: 8 additions & 4 deletions contrib/iedit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ specific to `iedit state`.
Key Binding | Description
------------------|------------------------------------------------------------
<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>TAB</kbd> | toggle current occurrence
<kbd>0</kbd> | go to the beginning of the current occurrence
<kbd>$</kbd> | go to the end of the current occurrence
<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>A</kbd> | go to the end of the current occurrence and switch to `iedit-insert state`
<kbd>D</kbd> | delete the occurrences
<kbd>F</kbd> | restrict the scope to the function
<kbd>gg</kbd> | go to first occurrence
<kbd>G</kbd> | go to last occurrence
<kbd>I</kbd> | go to the end of the current occurrence and switch to `iedit-insert state`
<kbd>I</kbd> | go to the beginning of the current occurrence and switch to `iedit-insert state`
<kbd>J</kbd> | increase the edition scope by one line below
<kbd>K</kbd> | increase the edition scope by one line above
<kbd>L</kbd> | restrict the scope to the current line
Expand All @@ -85,6 +86,9 @@ specific to `iedit state`.
<kbd>U</kbd> | Up-case the occurrences
<kbd>C-U</kbd> | down-case the occurrences

**Note:** <kbd>0</kbd>, <kbd>$</kbd>, <kbd>A</kbd> and <kbd>I</kbd> have the
default Vim behavior when used outside of an occurrence.

### In iedit-insert state

Key Binding | Description
Expand Down
2 changes: 0 additions & 2 deletions contrib/iedit/extensions.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
;; activate leader in iedit and iedit-insert states
(define-key evil-iedit-state-map
(kbd evil-leader/leader) evil-leader--default-map)
(define-key evil-iedit-insert-state-map
(kbd evil-leader/leader) evil-leader--default-map)
;; evil-escape support
(when (and (boundp 'evil-escape-mode)
(symbol-value evil-escape-mode))
Expand Down
43 changes: 31 additions & 12 deletions contrib/iedit/extensions/evil-iedit-state/evil-iedit-state.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ If INTERACTIVE is non-nil then COMMAND is called interactively."

(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))))
(let ((overlay (iedit-find-current-occurrence-overlay)))
(if overlay
(goto-char (overlay-start overlay))
(call-interactively 'evil-digit-argument-or-evil-beginning-of-line))))

(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))))
(let ((overlay (iedit-find-current-occurrence-overlay)))
(if overlay
(goto-char (overlay-end overlay))
(call-interactively 'evil-end-of-line))))

(defun evil-iedit-state/evil-beginning-of-line (count)
"Go to the beginning of the current overlay."
Expand Down Expand Up @@ -84,22 +90,32 @@ If INTERACTIVE is non-nil then COMMAND is called interactively."
(interactive)
(evil-iedit-state||swith-to-insert-state-after-command evil-change t))

(defun evil-iedit-state/paste-replace (count)
"Replace the selection with the yanked text."
(interactive "P")
(iedit-delete-occurrences)
(evil-paste-before count))

(defun evil-iedit-state/evil-append ()
"Append and switch to `iedit-insert state'"
(interactive)
(evil-iedit-state||swith-to-insert-state-after-command evil-append t))

(defun evil-iedit-state/evil-open-below ()
"Insert new line below and switch to `iedit-insert state'"
(interactive)
(evil-iedit-state||swith-to-insert-state-after-command evil-open-below t))

(defun evil-iedit-state/evil-open-above ()
"Insert new line above and switch to `iedit-insert state'"
(interactive)
(evil-iedit-state||swith-to-insert-state-after-command evil-open-above t))

(defun evil-iedit-state/evil-substitute ()
"Append and switch to `iedit-insert state'"
(interactive)
(evil-iedit-state||swith-to-insert-state-after-command evil-substitute t))

(defun evil-iedit-state/paste-replace (count)
"Replace the selection with the yanked text."
(interactive "P")
(iedit-delete-occurrences)
(evil-paste-before count))

;; expand-region integration, add an "e" command
(eval-after-load 'expand-region
'(progn
Expand Down Expand Up @@ -164,18 +180,21 @@ the initial string globally."
(define-key evil-iedit-state-map "L" 'iedit-restrict-current-line)
(define-key evil-iedit-state-map "n" 'iedit-next-occurrence)
(define-key evil-iedit-state-map "N" 'iedit-prev-occurrence)
(define-key evil-iedit-state-map "o" 'evil-iedit-state/evil-open-below)
(define-key evil-iedit-state-map "O" 'evil-iedit-state/evil-open-above)
(define-key evil-iedit-state-map "p" 'evil-iedit-state/paste-replace)
(define-key evil-iedit-state-map "s" 'evil-iedit-state/evil-substitute)
(define-key evil-iedit-state-map "S" 'evil-iedit-state/substitute)
(define-key evil-iedit-state-map "V" 'iedit-toggle-unmatched-lines-visible)
(define-key evil-iedit-state-map "U" 'iedit-upcase-occurrences)
(define-key evil-iedit-state-map "C-U" 'iedit-downcase-occurrences)
(define-key evil-iedit-state-map "\C-g" 'evil-iedit-state/quit-iedit-mode)
(define-key evil-iedit-state-map (kbd "C-U") 'iedit-downcase-occurrences)
(define-key evil-iedit-state-map (kbd "C-g")'evil-iedit-state/quit-iedit-mode)
(define-key evil-iedit-state-map [tab] 'iedit-toggle-selection)
(define-key evil-iedit-state-map [backspace] 'iedit-blank-occurrences)
(define-key evil-iedit-state-map [escape] '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 (kbd "C-g") 'evil-iedit-state/quit-iedit-mode)
(define-key evil-iedit-insert-state-map [escape] 'evil-iedit-state)

;; unbound iedit commands:
;; toggle buffering
Expand Down

0 comments on commit 5fb8a50

Please sign in to comment.