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

Re: vicmd bindings



> The most likely answer is that ksh's vi emulation is imperfect, and zsh
> intentionally emulated ksh rather than emulating the real vi.

I've tried a few kshes and they all behave exactly like bash.
That is, ESC-j and -k move the cursor to the very beginning of
the line.  However, I think that matching vi's behavior would be
more useful, and this patch aims toward that.

Unresolved problems include a poor choice in widget nomenclature
and a failure to keep the value of what cs should be across whatever
it is that determines cursor state boundaries.

I'll leave this uncommitted for a bit.

Index: Src/Zle/iwidgets.list
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v
retrieving revision 1.3
diff -u -r1.3 iwidgets.list
--- Src/Zle/iwidgets.list	2000/04/12 08:24:16	1.3
+++ Src/Zle/iwidgets.list	2000/12/20 01:45:35
@@ -121,6 +121,7 @@
 "vi-delete-char", videletechar, ZLE_KEEPSUFFIX
 "vi-digit-or-beginning-of-line", vidigitorbeginningofline, 0
 "vi-down-line-or-history", vidownlineorhistory, ZLE_LINEMOVE
+"vi-j-down-line-or-history", vijdownlineorhistory, ZLE_LINEMOVE
 "vi-end-of-line", viendofline, ZLE_LASTCOL
 "vi-fetch-history", vifetchhistory, 0
 "vi-find-next-char", vifindnextchar, 0
@@ -166,6 +167,7 @@
 "vi-undo-change", viundochange, ZLE_KEEPSUFFIX
 "vi-unindent", viunindent, 0
 "vi-up-line-or-history", viuplineorhistory, ZLE_LINEMOVE
+"vi-k-up-line-or-history", vikuplineorhistory, ZLE_LINEMOVE
 "vi-yank", viyank, 0
 "vi-yank-eol", viyankeol, 0
 "vi-yank-whole-line", viyankwholeline, 0
Index: Src/Zle/zle_bindings.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_bindings.c,v
retrieving revision 1.3
diff -u -r1.3 zle_bindings.c
--- Src/Zle/zle_bindings.c	2000/12/18 02:14:57	1.3
+++ Src/Zle/zle_bindings.c	2000/12/20 01:46:11
@@ -396,8 +396,8 @@
     /* g */ z_undefinedkey,
     /* h */ z_vibackwardchar,
     /* i */ z_viinsert,
-    /* j */ z_downlineorhistory,
-    /* k */ z_uplineorhistory,
+    /* j */ z_vijdownlineorhistory,
+    /* k */ z_vikuplineorhistory,
     /* l */ z_viforwardchar,
     /* m */ z_visetmark,
     /* n */ z_virepeatsearch,
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.1.1.14
diff -u -r1.1.1.14 zle_hist.c
--- Src/Zle/zle_hist.c	2000/02/23 15:18:49	1.1.1.14
+++ Src/Zle/zle_hist.c	2000/12/20 01:46:14
@@ -142,6 +142,17 @@
 
 /**/
 int
+vikuplineorhistory(char **args)
+{
+    int col = lastcol, oldcs = cs;
+    uplineorhistory(args);
+    lastcol = col;
+    cs = (oldcs > findeol()) ? findeol() : oldcs;
+    return 0;
+}
+
+/**/
+int
 uplineorsearch(char **args)
 {
     int ocs = cs;
@@ -222,6 +233,17 @@
     downlineorhistory(args);
     lastcol = col;
     return vifirstnonblank(zlenoargs);
+}
+
+/**/
+int
+vijdownlineorhistory(char **args)
+{
+    int col = lastcol, oldcs = cs;
+    downlineorhistory(args);
+    lastcol = col;
+    cs = (oldcs > findeol()) ? findeol() : oldcs;
+    return 0;
 }
 
 /**/



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