zsh-users
 help / color / mirror / code / Atom feed
From: zzapper <david@tvis.co.uk>
To: zsh-users@sunsite.dk
Subject: Re: CLI Tricks
Date: Fri, 12 Dec 2003 17:25:07 +0000	[thread overview]
Message-ID: <7cujtv8nifrbfpi5ogml7fbg6dietptckl@4ax.com> (raw)
In-Reply-To: <1031212164246.ZM3905@candle.brasslantern.com>

On Fri, 12 Dec 2003 16:42:46 +0000, Bart Schaefer
<schaefer@brasslantern.com> 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


  reply	other threads:[~2003-12-12 17:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-12 11:32 zzapper
2003-12-12 11:38 ` zzapper
2003-12-12 16:42   ` Bart Schaefer
2003-12-12 17:25     ` zzapper [this message]
2003-12-12 18:19     ` Peter Stephenson
2003-12-12 18:40   ` Pavol Juhas
2003-12-12 11:48 ` Dominik Vogt
2003-12-12 11:56   ` zzapper
2003-12-12 12:39     ` Thomas Köhler
2003-12-12 14:58       ` zzapper
2003-12-12 15:11   ` Hisham Muhammad
2003-12-12 17:10     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cujtv8nifrbfpi5ogml7fbg6dietptckl@4ax.com \
    --to=david@tvis.co.uk \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).