On 2008-10-16, Larry Clapp <[EMAIL PROTECTED]> wrote: > On Thu, Oct 16, 2008 at 09:12:23AM +0000, Andre Majorel wrote: >> On 2008-10-16, Aharon Robbins <[EMAIL PROTECTED]> wrote: >> > In article <[EMAIL PROTECTED]>, >> > Andre Majorel <[EMAIL PROTECTED]> wrote: >> >>Vi mode would help, but in Bash, there's no way to switch between >> >>it and Emacs mode on the fly. >> > >> > Au contraire: >> > >> > set -o vi >> > set -o emacs >> >> By "on the fly", I didn't mean in the middle of a Bash session but >> in the middle of editing a command line. For some reason, Esc ^J is >> a no-op in Bash. > > That's because it's not bound: > > zsh> bash > [EMAIL PROTECTED]:~$ bind -m emacs -p | grep -i m-.c-j > [ no output ] > [EMAIL PROTECTED]:~$ bind -m vi -p | grep -i c-e > [ no output ]
More precisely, because it's been explicitly unbound : http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=198634 | "Marcelo E. Magallon" : | Oh, btw, I can't get C-M-j to work. Perhaps I need to | figure out which key is Meta. I thought it was "Alt" (which | xkeycaps confirms), but no cigar... | | Chet Ramey : | It doesn't work in bash. Bash disables it because `set -o | emacs' and `set -o vi' exist. There is text in the readline | manual that is conditionally included depending on whether or | not the text is part of the bash manual or standalone. The | standalone version includes the M-C-j stuff; the bash version | includes `set -o {emacs,vi}' If you don't quite see the relationship of cause and effect implied by the word "because" between "set -o {vi,emacs} exist" and "Bash disables [M-C-j]", me neither, but there you have it. > But you can bind the standard Readline keys for those commands: > > [EMAIL PROTECTED]:~$ bind -m emacs '"\e\C-J": vi-editing-mode' > [EMAIL PROTECTED]:~$ bind -m vi '"\C-E": emacs-editing-mode' Thanks, that worked. Put this in my .inputrc (not tested in vi mode) : # [ù] to switch between vi and Emacs mode set keymap emacs ù: vi-editing-mode set keymap vi-command ù: emacs-editing-mode set keymap vi-insert ù: emacs-editing-mode set keymap vi-move ù: emacs-editing-mode With this, you can move to the next-to-last path component with [ù] [Esc] [2] [T] [/] [ù] (7 key presses) instead of the wrist-twisting, console-verboten [Esc] [Ctrl]-[]] [/] [Esc] [Ctrl]-[]] [/] [Right] (13 key presses). Still, not nearly as good as [Ctrl]-[T] [Ctrl]-[T] (3 key presses). One problem solved, four to go. <g> -- André Majorel <URL:http://www.teaser.fr/~amajorel/> You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists -- Abbie Hoffman.