From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9064 invoked from network); 12 Dec 2003 17:25:26 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 12 Dec 2003 17:25:26 -0000 Received: (qmail 13208 invoked by alias); 12 Dec 2003 17:25:14 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6871 Received: (qmail 13158 invoked from network); 12 Dec 2003 17:25:14 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 12 Dec 2003 17:25:14 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [80.91.224.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 12 Dec 2003 17:25:14 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AUr2P-0005Zq-00 for ; Fri, 12 Dec 2003 18:25:13 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@sunsite.dk Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AUr2O-0005Zi-00 for ; Fri, 12 Dec 2003 18:25:12 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AUr2O-0000m4-00 for ; Fri, 12 Dec 2003 18:25:12 +0100 From: zzapper Subject: Re: CLI Tricks Date: Fri, 12 Dec 2003 17:25:07 +0000 Message-ID: <7cujtv8nifrbfpi5ogml7fbg6dietptckl@4ax.com> References: <25ajtv4u5ps1npttivtiguuljeb27f0u4m@4ax.com> <1031212164246.ZM3905@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Newsreader: Forte Free Agent 1.93/32.576 English (American) Sender: news On Fri, 12 Dec 2003 16:42:46 +0000, Bart Schaefer wrote: >[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. Thankx but ARGGH!! Maybe this is for somebody a lot higher up the learning curve. BTW I expect vi to start in command mode because that's how real vi(m) starts. zzapper -- vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips