* CLI Tricks @ 2003-12-12 11:32 zzapper 2003-12-12 11:38 ` zzapper 2003-12-12 11:48 ` Dominik Vogt 0 siblings, 2 replies; 12+ messages in thread From: zzapper @ 2003-12-12 11:32 UTC (permalink / raw) To: zsh-users Hi Ya A) I use bindkey -v (vi emulation) is there any where to get it start in on-insert mode (ie command mode) B) I've read somewhere that I can repeat the previous keyword when typing a command eg > cp verylongfilename (control metachar) and you get > cp verylongfilename verylongfilename But I couldn't get it to work. 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:32 CLI Tricks zzapper @ 2003-12-12 11:38 ` zzapper 2003-12-12 16:42 ` Bart Schaefer 2003-12-12 18:40 ` Pavol Juhas 2003-12-12 11:48 ` Dominik Vogt 1 sibling, 2 replies; 12+ messages in thread From: zzapper @ 2003-12-12 11:38 UTC (permalink / raw) To: zsh-users > >is there any where to get it start in non-insert mode (ie command mode) > I meant NON-INSERT 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:38 ` zzapper @ 2003-12-12 16:42 ` Bart Schaefer 2003-12-12 17:25 ` zzapper 2003-12-12 18:19 ` Peter Stephenson 2003-12-12 18:40 ` Pavol Juhas 1 sibling, 2 replies; 12+ messages in thread From: Bart Schaefer @ 2003-12-12 16:42 UTC (permalink / raw) To: zsh-users [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. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 16:42 ` Bart Schaefer @ 2003-12-12 17:25 ` zzapper 2003-12-12 18:19 ` Peter Stephenson 1 sibling, 0 replies; 12+ messages in thread From: zzapper @ 2003-12-12 17:25 UTC (permalink / raw) To: zsh-users 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 16:42 ` Bart Schaefer 2003-12-12 17:25 ` zzapper @ 2003-12-12 18:19 ` Peter Stephenson 1 sibling, 0 replies; 12+ messages in thread From: Peter Stephenson @ 2003-12-12 18:19 UTC (permalink / raw) To: zsh-users Bart Schaefer wrote: > Now bind it to ALL the insert widgets in the vistartup keymap. >... > 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. Hmm... I'm not sure about this. We discussed simply being able to bind `main' to vicmd and tweaking the way viins and vicmd were hooked together. It was easy to implement but it wasn't popular for some technical reason I've forgotten. The other way of doing it is to add a hook widget to zle to run every time it starts. That's not too hard, either, but nobody's got around to doing it. pws ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:38 ` zzapper 2003-12-12 16:42 ` Bart Schaefer @ 2003-12-12 18:40 ` Pavol Juhas 1 sibling, 0 replies; 12+ messages in thread From: Pavol Juhas @ 2003-12-12 18:40 UTC (permalink / raw) To: zsh users On Fri, Dec 12, 2003 at 11:38:34AM +0000, zzapper wrote: > > > >is there any where to get it start in non-insert mode (ie command mode) > > > I meant NON-INSERT You can do # my-cr() pushes \r\e to zle buffer as if typed my-cr() { zle -U $'\r\e' } # define my-cr as widget function zle -N my-cr my-cr # insert mode maps bindkey '^m' my-cr bindkey '^j' my-cr # command mode maps bindeky -a '^m' my-cr bindeky -a '^j' my-cr which remaps <cr> to <cr><esc>. The very first input would be in insert mode, but maybe you can live with that. ;-) Pavol ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:32 CLI Tricks zzapper 2003-12-12 11:38 ` zzapper @ 2003-12-12 11:48 ` Dominik Vogt 2003-12-12 11:56 ` zzapper 2003-12-12 15:11 ` Hisham Muhammad 1 sibling, 2 replies; 12+ messages in thread From: Dominik Vogt @ 2003-12-12 11:48 UTC (permalink / raw) To: zzapper, Zsh Users On Fri, Dec 12, 2003 at 11:32:39AM +0000, zzapper wrote: > B) > > I've read somewhere that I can repeat the previous keyword when typing > a command > > eg > > > cp verylongfilename (control metachar) > > and you get > > > cp verylongfilename verylongfilename You want the copy-prev-word function which is by default bound to Esc Ctrl-_ Ciao Dominik ^_^ ^_^ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:48 ` Dominik Vogt @ 2003-12-12 11:56 ` zzapper 2003-12-12 12:39 ` Thomas Köhler 2003-12-12 15:11 ` Hisham Muhammad 1 sibling, 1 reply; 12+ messages in thread From: zzapper @ 2003-12-12 11:56 UTC (permalink / raw) To: zsh-users On Fri, 12 Dec 2003 12:48:09 +0100, Dominik Vogt <dominik.vogt@gmx.de> wrote: >> >> > cp verylongfilename verylongfilename > >You want the copy-prev-word function which is by default bound to >Esc Ctrl-_ Is it disabled if you use bindkey -v Cos I cant get it to work EscControl_ It works with bindkey -e But then on my keyboard me its EscCTRLShift_ which rather negates its usefulness!!! 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:56 ` zzapper @ 2003-12-12 12:39 ` Thomas Köhler 2003-12-12 14:58 ` zzapper 0 siblings, 1 reply; 12+ messages in thread From: Thomas Köhler @ 2003-12-12 12:39 UTC (permalink / raw) To: zzapper; +Cc: zsh-users [-- Attachment #1: Type: text/plain, Size: 959 bytes --] Hi, zzapper wrote: > On Fri, 12 Dec 2003 12:48:09 +0100, Dominik Vogt <dominik.vogt@gmx.de> > wrote: > > >> > cp verylongfilename verylongfilename > > > >You want the copy-prev-word function which is by default bound to > >Esc Ctrl-_ > > Is it disabled if you use bindkey -v > > Cos I cant get it to work Sure. man zshzle and search for copy-prev-word - it says it's unbound for vi insert or command modes :) > EscControl_ > > It works with bindkey -e > > But then on my keyboard me its EscCTRLShift_ which rather negates its > usefulness!!! bindkey -M viins '^O' copy-prev-word And use ctrl-o afterwards. Or use another key which suits you better. Ciao, Thomas -- Thomas Köhler Email: jean-luc@picard.franken.de <>< WWW: http://jeanluc-picard.de IRC: tkoehler PGP public key available from Homepage! [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 12:39 ` Thomas Köhler @ 2003-12-12 14:58 ` zzapper 0 siblings, 0 replies; 12+ messages in thread From: zzapper @ 2003-12-12 14:58 UTC (permalink / raw) To: zsh-users On Fri, 12 Dec 2003 13:39:28 +0100, Thomas Köhler <jean-luc@picard.franken.de> wrote: Jean Luc >bindkey -M viins '^O' copy-prev-word > And use ctrl-o afterwards. Thanx, just what the doctor ordered! Is it possible to configure >bindkey -v to start up in command mode rather than insert mode? 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 11:48 ` Dominik Vogt 2003-12-12 11:56 ` zzapper @ 2003-12-12 15:11 ` Hisham Muhammad 2003-12-12 17:10 ` Bart Schaefer 1 sibling, 1 reply; 12+ messages in thread From: Hisham Muhammad @ 2003-12-12 15:11 UTC (permalink / raw) To: zsh-users On Friday 12 December 2003 09:48, you wrote: > On Fri, Dec 12, 2003 at 11:32:39AM +0000, zzapper wrote: > > B) > > > > I've read somewhere that I can repeat the previous keyword when typing > > a command > > > > eg > > > > > cp verylongfilename (control metachar) > > > > and you get > > > > > cp verylongfilename verylongfilename > > You want the copy-prev-word function which is by default bound to > Esc Ctrl-_ How interesting! Didn't know about that. I played a bit with it and was intrigued by its behavior with filenames with spaces, but then 'man zshzle' told me there's a copy-prev-shell-word which does the same but works with spaces. The manpage, however, says both are bound to the same key by default (a documentation bug?). -- Hisham Muhammad "...and this is the first step." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: CLI Tricks 2003-12-12 15:11 ` Hisham Muhammad @ 2003-12-12 17:10 ` Bart Schaefer 0 siblings, 0 replies; 12+ messages in thread From: Bart Schaefer @ 2003-12-12 17:10 UTC (permalink / raw) To: zsh-users On Dec 12, 1:11pm, Hisham Muhammad wrote: } } > You want the copy-prev-word function } } 'man zshzle' told me there's a copy-prev-shell-word which does the } same but works with spaces. The manpage, however, says both are bound } to the same key by default (a documentation bug?). Yes, it's a doc bug; copy-prev-shell-word is a recent addition, and the entry for it was created by cut+paste+edit of the copy-prev-word entry. Index: Doc/Zsh/zle.yo =================================================================== --- zle.yo 23 Sep 2003 15:27:14 -0000 1.9 +++ zle.yo 12 Dec 2003 17:07:53 -0000 @@ -1184,7 +1184,7 @@ Duplicate the word to the left of the cursor. ) tindex(copy-prev-shell-word) -item(tt(copy-prev-shell-word) (ESC-^_) (unbound) (unbound))( +item(tt(copy-prev-shell-word))( Like tt(copy-prev-word), but the word is found by using shell parsing, whereas tt(copy-prev-word) looks for blanks. This makes a difference when the word is quoted and contains spaces. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-12-12 18:40 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-12-12 11:32 CLI Tricks zzapper 2003-12-12 11:38 ` zzapper 2003-12-12 16:42 ` Bart Schaefer 2003-12-12 17:25 ` zzapper 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
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).