diff options
| author | Ankit Pandey <anpandey@protonmail.com> | 2023-04-19 23:25:59 -0700 |
|---|---|---|
| committer | Axel Forsman <axelsfor@gmail.com> | 2023-08-28 15:42:42 +0200 |
| commit | d6d2e5d2b170eb0ab3bec488868702009a0ee3b6 (patch) | |
| tree | 3bd72440fb94359583fdea766fd1641d8c679975 | |
| parent | 657af37c5570caab487e9e73d7b95696437e664d (diff) | |
tabs: Go to nth tab when tab-next is prefixed
This emulates the behavior of vim, where {N}gt goes to the Nth tab,
but {N}gT goes back N tabs.
| -rw-r--r-- | evil-commands.el | 12 | ||||
| -rw-r--r-- | evil-maps.el | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/evil-commands.el b/evil-commands.el index 3d625a7..2198a0c 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -4782,6 +4782,18 @@ and redisplay the current buffer there." :repeat nil (evil-move-window 'below)) +;;; Tab commands + +(evil-define-command evil-tab-next (arg) + "Switch to the next tab. +If ARG is non-nil, parse ARG as an index and go to the tab at that +index." + :repeat nil + (interactive "<c>") + (if arg + (tab-bar-select-tab arg) + (tab-bar-switch-to-next-tab))) + ;;; Mouse handling ;; Large parts of this code are taken from mouse.el which is diff --git a/evil-maps.el b/evil-maps.el index f263a63..2834d5a 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -189,8 +189,8 @@ (define-key evil-window-map [C-right] 'evil-window-right) (when (featurep 'tab-bar) - (define-key evil-motion-state-map "gt" 'tab-bar-switch-to-next-tab) - (define-key evil-window-map "gt" 'tab-bar-switch-to-next-tab) + (define-key evil-motion-state-map "gt" 'evil-tab-next) + (define-key evil-window-map "gt" 'evil-tab-next) (define-key evil-motion-state-map "gT" 'tab-bar-switch-to-prev-tab) (define-key evil-window-map "gT" 'tab-bar-switch-to-prev-tab)) @@ -588,7 +588,7 @@ included in `evil-insert-state-bindings' by default." (evil-ex-define-cmd "tabnew" 'tab-bar-new-tab) (evil-ex-define-cmd "tabc[lose]" 'tab-bar-close-tab) (evil-ex-define-cmd "tabo[nly]" 'tab-bar-close-other-tabs) - (evil-ex-define-cmd "tabn[ext]" 'tab-bar-switch-to-next-tab) + (evil-ex-define-cmd "tabn[ext]" 'evil-tab-next) (evil-ex-define-cmd "tabp[revious]" 'tab-bar-switch-to-prev-tab)) ;; Command-line editing |
