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 ] or put another way: [EMAIL PROTECTED]:~$ bind -m emacs -p | grep editing-mode # emacs-editing-mode (not bound) # vi-editing-mode (not bound) [EMAIL PROTECTED]:~$ bind -m vi -p | grep editing-mode # emacs-editing-mode (not bound) # vi-editing-mode (not bound) 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' Check: [EMAIL PROTECTED]:~$ bind -m emacs -p | grep -i m-.c-j "\M-\C-j": vi-editing-mode [EMAIL PROTECTED]:~$ bind -m vi -p | grep -i c-e "\C-e": emacs-editing-mode [EMAIL PROTECTED]:~$ bind -m emacs -p | grep editing-mode # emacs-editing-mode (not bound) "\M-\C-j": vi-editing-mode [EMAIL PROTECTED]:~$ bind -m vi -p | grep editing-mode "\C-e": emacs-editing-mode # vi-editing-mode (not bound) I could not get "bind -m emacs '"\M-\C-J: vi-editing-mode' to work directly, it always came out like this: [EMAIL PROTECTED]:~$ bind -m emacs '"\M-\C-J": vi-editing-mode' [EMAIL PROTECTED]:~$ bind -q vi-editing-mode | less vi-editing-mode can be invoked via "<DC>C-J". # ^^^^ so I'm probably missing some subtle Readline meta-related setting. Note that the editing mode is not reset when you finish the current command, but changed permanently. Keeping straight which mode you're in is left as an exercise to the reader. -- Larry