branch: elpa/evil commit d706e4002d63986c81a3fe2aa99517570b4e5c8d Author: Tom Dalziel <33435574+tomd...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Add i_0_CTRL-D functionality (#1547) --- evil-commands.el | 13 ++++++++++++- evil-tests.el | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 6e99996..dc8a2e7 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1989,6 +1989,13 @@ See also `evil-shift-left'." (t (move-to-column (or goal-column evil-operator-start-col)))) (setq temporary-goal-column 0))) +(defun evil-delete-indentation () + "Delete all indentation on current line." + (interactive) + (save-excursion + (evil-beginning-of-line) + (delete-region (point) (progn (skip-chars-forward " \t") (point))))) + (evil-define-command evil-shift-right-line (count) "Shift the current line COUNT times to the right. The text is shifted to the nearest multiple of @@ -2003,7 +2010,11 @@ The text is shifted to the nearest multiple of `evil-shift-width'. Like `evil-shift-left' but always works on the current line." (interactive "<c>") - (evil-shift-left (line-beginning-position) (line-beginning-position 2) count t)) + (if (and (eq 'self-insert-command last-command) + (eq ?0 (char-before))) + (progn (backward-delete-char 1) + (evil-delete-indentation)) + (evil-shift-left (line-beginning-position) (line-beginning-position 2) count t))) (evil-define-operator evil-align-left (beg end type &optional width) "Right-align lines in the region at WIDTH columns. diff --git a/evil-tests.el b/evil-tests.el index 9074e22..4827486 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -2357,7 +2357,12 @@ Below some empty line"))) ("i\C-t\C-t") "line 1\n l[i]ne 2\nline 3\n" ("\C-d") - "line 1\n l[i]ne 2\nline 3\n")))) + "line 1\n l[i]ne 2\nline 3\n")) + (ert-info ("Delete all indentation in insert state") + (evil-test-buffer + "line1\n sometext[ ]" + ("a" "somemore" "0\C-d") + "line1\nsometext somemore[]")))) ;;; Paste