From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7480 invoked from network); 12 Dec 2003 16:43:43 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 12 Dec 2003 16:43:43 -0000 Received: (qmail 10874 invoked by alias); 12 Dec 2003 16:42:49 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6869 Received: (qmail 10807 invoked from network); 12 Dec 2003 16:42:48 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 12 Dec 2003 16:42:48 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.11.8.53] by sunsite.dk (MessageWall 1.0.8) with SMTP; 12 Dec 2003 16:42:48 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id hBCGgkj03906 for zsh-users@sunsite.dk; Fri, 12 Dec 2003 08:42:46 -0800 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1031212164246.ZM3905@candle.brasslantern.com> Date: Fri, 12 Dec 2003 16:42:46 +0000 In-Reply-To: <25ajtv4u5ps1npttivtiguuljeb27f0u4m@4ax.com> Comments: In reply to zzapper "Re: CLI Tricks" (Dec 12, 11:38am) References: <25ajtv4u5ps1npttivtiguuljeb27f0u4m@4ax.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: CLI Tricks MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii [zzapper seems to be unusually good at running afoul of verizon's mail filtering. I've failed to receive the _first_ message in nearly every thread he's started. The Sunsite staff tells me they think it's because their servers get temporarily listed by SpamCop, but why would zzapper in particular be the one to always hit them during SpamCop blackouts?] On Dec 12, 11:38am, zzapper wrote: } } I meant NON-INSERT [With regard to starting in vi command mode] The short answer is, no, you can't, not without a bit of programming. Vi mode works by changing zsh's "main" keymap to be the "viinsert" map (normally it's the "emacs" map). Command mode switches temporarily to the "vicmd" keymap, but the keys in that map that would return you to insert mode are all programmed to return you to the "main" map, not to the "viinsert" map. This is to allow invoking vicmd from a bindkey in the emacs map without becoming trapped in vi mode. So you could force zsh to start in vi command mode by making vicmd be the main map, but then you can never get back to insert mode. The way to program around this is to first copy the vicmd keymap: bindey -N vistartup vicmd Next, create a widget function that restores "viinsert" as the main keymap, and then calls through to a builtin widget. You're going to have to bind this to every key that might change to insert mode, so it helps if it's generic: reset-vi-and-call () { local widget="${WIDGET#reset-}" bindkey -v zle $widget } Now bind it to ALL the insert widgets in the vistartup keymap. I'm only going to show how you do this for "i" and "a", because it's very monotonous: zle -N reset-vi-insert reset-vi-and-call bindkey -M vistartup i reset-vi-insert zle -N reset-vi-add-next reset-vi-and-call bindkey -M vistartup a reset-vi-add-next Finally, set up your precmd function to force the main keymap to be the vistartup keymap, because you have to reinitialize this every time zsh re-enters ZLE: precmd () { # Any other stuff you already have in precmd stays here bindkey -A vistartup main } That's all. If you (or anyone) actually codes the rest of this up and tests it, send the result to zsh-workers so we can consider including it in the zsh distribution.