summaryrefslogtreecommitdiff
path: root/modes/vterm
diff options
context:
space:
mode:
authorJakub Kadlcik <frostyx@email.cz>2022-04-28 12:04:35 -0400
committerYoumu <condy0919@gmail.com>2022-05-02 01:11:49 +0800
commit3d853e67af8257131c31e202939141adbf496a73 (patch)
treea1e8027dbcec2a844514aa9c6181104022c5e6d7 /modes/vterm
parentc8366be12490b1cf9b4e5dff05522e416bb2ba9c (diff)
vterm: use ^ for jumping at the beginning of the command but after prompt
We have `0` for jumping at the very first character of the current line and `^` for jumping to the non-blank character. It is useful to keep this distinction in `vterm` buffers. However, it doesn't make much sense in the command part. Because we have a prompt, both of the commands jump to the very first character. I think it would be more useful to change `^` to jump to the first non-blank character after the prompt.
Diffstat (limited to 'modes/vterm')
-rw-r--r--modes/vterm/evil-collection-vterm.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/modes/vterm/evil-collection-vterm.el b/modes/vterm/evil-collection-vterm.el
index 3681586..a2412ad 100644
--- a/modes/vterm/evil-collection-vterm.el
+++ b/modes/vterm/evil-collection-vterm.el
@@ -67,6 +67,17 @@ also uses `evil-mode'."
"vterm"
"emacs"))))
+(declare-function vterm-cursor-in-command-buffer-p "vterm")
+(declare-function vterm-beginning-of-line "vterm")
+
+(evil-define-motion evil-collection-vterm-first-non-blank ()
+ "Move the cursor to the first non-blank character
+after the prompt."
+ :type exclusive
+ (if (vterm-cursor-in-command-buffer-p (point))
+ (vterm-beginning-of-line)
+ (evil-first-non-blank)))
+
(defun evil-collection-vterm-insert ()
"Insert character before cursor."
(interactive)
@@ -232,6 +243,7 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
"D" 'evil-collection-vterm-delete-line
"x" 'evil-collection-vterm-delete-backward-char
(kbd "RET") 'vterm-send-return
+ "^" 'evil-collection-vterm-first-non-blank
"i" 'evil-collection-vterm-insert
"I" 'evil-collection-vterm-insert-line
"u" 'vterm-undo