4

This has bothered me for years. I have tried to unbind the key sequence in .inputrc, I have set EDITOR to true and false, I have read and reread the bash and readline man pages. I have used ksh instead of bash.

How do I disable the behavior of Esc followed by v keyboard sequence?

1
  • EDITOR is not a Boolean variable. It specifies the preferred editor to use. KSH, for example, is going to look at what you set it to and try to decide whether to use the emacs or vi editors on the command line. I'm not sure whether BASH has the same sort of heuristic. – Marc Wilson Jun 10 at 18:07
12

It looks like you're unknowingly using bash in its vi mode.

In vi mode, bash, like vi has an insert mode where you can insert text (and a replace mode which is a variation on that) and a command mode where you can enter motion or action commands such as x to delete a character, b to move back one word, etc.

You switch from insert/replace mode to command mode with Esc, and a few commands such as i, a, A, s... can make you enter insert mode from command mode.

In command mode, the v command brings up an editor to edit the current line (the vi editor had no command bound to v, so ksh (on which bash is based) was free to use that for that specific task).

Here, it sounds to me that you're not expecting to be using the vi style of key binding. bash/readline's default key binding is emacs, not vi, so I suspect you or your system administrator has introduced some customisation that enables the vi mode by default.

It could be by adding a set -o vi in /etc/bashrc or /etc/bash.bashrc wherever the system default customisation file for bash is on your system, or set editing-mode vi in /etc/inputrc.

Or it could be that you have similar settings in your own ~/.bashrc or ~/.inputrc.

You'd likely want to change it back to set -o emacs in ~/.bashrc or set editing-mode emacs in ~/.inputrc.

Note that the emacs mode has a similar function bound to Ctrl+XCtrl+E

If you're expecting to be using the vi mode, and you don't want v to spawn an editor, then you can assign a widget to v other than edit-and-execute-command such as:

bind -m vi-command '"v": abort'

Or to an empty string so it's ignored:

bind -m vi-command '"v": ""'
1
  • 1
    Thank you, Thank you, bind -m vi-command '"v": ignore' is what I have wanted all of these years. I use vi a great deal, and use escape often to get into command mode. I prefer vi mode in my shell, because I use it for my editing. I have searched many times for "how to disable" but never found the exact right place to look. I even read the bash source code to no avail. Thank you very much. – Hinheckle Jones Jun 10 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.