Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] ZLE: Bind '_' to vi-first-non-blank in vicmd keymap



From 1a9312d1e0b9fc4205c1e52b19722723238ede7e Mon Sep 17 00:00:00 2001
From: AidanV <aidanvanduyne@xxxxxxxxx>
Date: Mon, 8 Dec 2025 00:58:25 +0000
Subject: [PATCH] ZLE: Bind '_' to vi-first-non-blank in vicmd keymap

In vim/vi, '_' moves to the first non-blank character of a line.
Zsh's vi-mode already provides `vi-first-non-blank` support. This
is currently bound to '^' in the keymap. This patch binds '_' to
`vi-first-non-blank` in the vicmd keymap so that Zsh behavior matches
vim/vi expectations.

---
 Doc/Zsh/zle.yo         | 2 +-
 Src/Zle/zle_bindings.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index a0d97a0c8..8c1cd078d 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1328,7 +1328,7 @@ Read a character from the keyboard, and move to
 the position just after the previous occurrence of it in the line.
 )
 tindex(vi-first-non-blank)
-item(tt(vi-first-non-blank) (unbound) (tt(^)) (unbound))(
+item(tt(vi-first-non-blank) (unbound) (tt(_ ^)) (unbound))(
 Move to the first non-blank character in the line.
 )
 tindex(vi-forward-word)
diff --git a/Src/Zle/zle_bindings.c b/Src/Zle/zle_bindings.c
index 55863db1b..74a62ab4d 100644
--- a/Src/Zle/zle_bindings.c
+++ b/Src/Zle/zle_bindings.c
@@ -385,7 +385,7 @@ int vicmdbind[128] = {
     /* \ */ z_undefinedkey,
     /* ] */ z_undefinedkey,
     /* ^ */ z_vifirstnonblank,
-    /* _ */ z_undefinedkey,
+    /* _ */ z_vifirstnonblank,
     /* ` */ z_vigotomark,
     /* a */ z_viaddnext,
     /* b */ z_vibackwardword,
-- 
2.43.0




Messages sorted by: Reverse Date, Date, Thread, Author