From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18988 invoked by alias); 4 Dec 2014 18:35:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33846 Received: (qmail 22846 invoked from network); 4 Dec 2014 18:35:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1417717712; bh=PmAIC2DZKTNfBeEzW4FgLh2ERooI3aNxTj6eYDv2Y7c=; h=From:To:Subject:Date:From:Subject; b=NITqRhwJ7/W+TojIeYk4ClkbwldpaKbiLpKo5AqlFMN95OT0+3QBYvUzZXqsjxiyHKEWM08Jm+yXJzns+rSI8T9S5gY4cpbsgYdTYDu8W4dJMDVIDOzWg4CzvMR47tZvZWmVfwx+eBm7nAqRdsYax+E9BGsuGZ10mbkJJXuUIL5Qsip23Os+3m+MmW8kOse/dGeqPTwcZ+9ykRQjJmMvuARlbFZm+2P4f6TrcPKlDI66reMolACCodY836c2dmV+T8ClPbhmQ8dAPl0D2kbGPTiVdxclwbog1EfPFggk3U3NkC1FSu1Ci5n7Y3le1IMHOI+26ixEPwXuUJ18iqlqBg== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=dqjfVSAIPBUEE9gaFwPWX8d9DQDG84NRljFd39K9mEPwuJBdPKmNFXHiH+96nC3Af/rX1gpwR9JoNPNHlfy9T3KRVjTC5s7lmTQr33MN5NpLgVEn1gghIz0LUOoderKKwexl2BeJNDOt81A++IaCOxjbwpiBwPLdbkeEciG6FXHRGAV5ynME9hEh4vhF+8gav/gdNIcKtQmfM5nRPpbeoW/gOOABiXSeipFW8DswwD24FMcVr7Rq0S6r/JZcrkITEqe1JqX/pKEWstgl5DfT9GfCz42ogI47mRAdrthfjF9je9tdSYUfujFbKEAPL7jq73l6J745XrlpuH0/4oK3jQ==; X-Yahoo-Newman-Id: 689825.85167.bm@smtp105.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: SGTWN08VM1kLWIdS0b2JuXVzp1W_p24EW1QBUJ7NlvOXTSw U1KFXE67y7TMF1dtmz9uSUeCqv2XCJgmLt7MJlD8W2hv16aryoSB_M0d55Hw cBb68ZPcwPDkmx8jZTOpMeQuvaBrDXFeetv81gt83uDbQY6l5LMi4gvM.nDh M5.tsGUxNUINsiv32A20uCX4_B8YQ77nqZUD5UoHL68VgegxfWc7ATVvyLOx tItnLDFpzg.qzXlrBO4Vh._H1kXi.wF9CPAiZwvq45I7WL516OPI4Uvg1JzS 1MpXIBZe3ZzIZ8.dq1AGgu32vOl59JEgsXWFWw0c9u0HR6mXjlIpXzLIA7Qt o.wRESRd1.seHxwq9WkWkxMWBd_oKBgkNs1UY_lj8.wfy2H3VZ0VV6uprKgz _hJVG.5Fd4eb4Dtk4alCgI9LRpWSurnP1j5t4eHbNPHYBY7lFYJIDwMnGklG rXRGXAYv2hfpoq5AY2T4ES56kifDgBBwmi6yEmDJFd_nik7rvsAcOddt29cc bYXpQJhD98m_R0VGW2uWDN_c_1c15xg-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: default vi-mode key bindings MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17051.1417717710.1@thecus.kiddle.eu> Date: Thu, 04 Dec 2014 19:28:30 +0100 Message-ID: <17052.1417717710@thecus.kiddle.eu> I would like to suggest the following changes to the default key bindings in vi mode. The undo bindings are a change to existing behaviour. I think it is better that someone has to explicitly select the vi-compatible single level undo/redo toggling and that the default is multi-level undo with redo on Ctrl-R. Ctrl-R is currently redisplay. The other keys are all vim bindings starting with a g prefix. gg is very common and well known. I've bound it to beginning-of-buffer-or-history. The beginning of history is really fairly useless but it probably needs to be that for consistency with other keys: I only care about it going to that start of the buffer. I'm slightly inclined to add a goto-line to go to a line in the buffer based on numeric argument. Note that G is bound to vi-fetch-history. That does go to the end of a buffer but not if you're on a previous history line. I use a combination of it with end-of-buffer-or-history in a custom widget. These should all be line-based moves within a vi buffer so the patch also sets those flags. Next is ga to what-cursor-position. ^G probably sooner comes to mind for that purpose but that's currently list-expand. ga in vim gives you the ASCII code of the character under the cursor, similarly to zsh's what-cursor-position. g~ is swap case (like ~) but with a movement command. I have vim's gu/gU implemented as shell functions. Finally, there are ge and gE for moving back to the end of the previous word. Any thoughts or other suggestions? Oliver diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list index 1a664e5..b3d1c92 100644 --- a/Src/Zle/iwidgets.list +++ b/Src/Zle/iwidgets.list @@ -24,7 +24,7 @@ "backward-kill-word", backwardkillword, ZLE_KILL | ZLE_KEEPSUFFIX "backward-word", backwardword, 0 "beep", handlefeep, 0 -"beginning-of-buffer-or-history", beginningofbufferorhistory, 0 +"beginning-of-buffer-or-history", beginningofbufferorhistory, ZLE_LINEMOVE "beginning-of-history", beginningofhistory, 0 "beginning-of-line", beginningofline, 0 "beginning-of-line-hist", beginningoflinehist, 0 @@ -46,7 +46,7 @@ "down-line-or-search", downlineorsearch, ZLE_LINEMOVE | ZLE_LASTCOL "emacs-backward-word", emacsbackwardword, 0 "emacs-forward-word", emacsforwardword, 0 -"end-of-buffer-or-history", endofbufferorhistory, 0 +"end-of-buffer-or-history", endofbufferorhistory, ZLE_LINEMOVE "end-of-history", endofhistory, 0 "end-of-line", endofline, 0 "end-of-line-hist", endoflinehist, 0 @@ -143,7 +143,7 @@ "vi-digit-or-beginning-of-line", vidigitorbeginningofline, 0 "vi-down-line-or-history", vidownlineorhistory, ZLE_LINEMOVE "vi-end-of-line", viendofline, ZLE_LASTCOL -"vi-fetch-history", vifetchhistory, 0 +"vi-fetch-history", vifetchhistory, ZLE_LINEMOVE "vi-find-next-char", vifindnextchar, 0 "vi-find-next-char-skip", vifindnextcharskip, 0 "vi-find-prev-char", vifindprevchar, 0 diff --git a/Src/Zle/zle_bindings.c b/Src/Zle/zle_bindings.c index 50a2955..e3337d0 100644 --- a/Src/Zle/zle_bindings.c +++ b/Src/Zle/zle_bindings.c @@ -308,7 +308,7 @@ int vicmdbind[128] = { /* ^O */ z_undefinedkey, /* ^P */ z_uphistory, /* ^Q */ z_undefinedkey, - /* ^R */ z_redisplay, + /* ^R */ z_redo, /* ^S */ z_undefinedkey, /* ^T */ z_undefinedkey, /* ^U */ z_undefinedkey, @@ -407,7 +407,7 @@ int vicmdbind[128] = { /* r */ z_vireplacechars, /* s */ z_visubstitute, /* t */ z_vifindnextcharskip, - /* u */ z_viundochange, + /* u */ z_undo, /* v */ z_visualmode, /* w */ z_viforwardword, /* x */ z_videletechar, diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 30d25eb..6957e9f 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1357,6 +1357,13 @@ default_bindings(void) bindkey(vismap, "x", refthingy(t_videlete), NULL); bindkey(vismap, "~", refthingy(t_vioperswapcase), NULL); + /* vi mode: some common vim bindings */ + bindkey(amap, "ga", refthingy(t_whatcursorposition), NULL); + bindkey(amap, "ge", refthingy(t_vibackwardwordend), NULL); + bindkey(amap, "gE", refthingy(t_vibackwardblankwordend), NULL); + bindkey(amap, "gg", refthingy(t_beginningofbufferorhistory), NULL); + bindkey(amap, "g~", refthingy(t_vioperswapcase), NULL); + /* emacs mode: arrow keys */ add_cursor_key(emap, TCUPCURSOR, t_uplineorhistory, 'A'); add_cursor_key(emap, TCDOWNCURSOR, t_downlineorhistory, 'B');