Re: how to use Esc to quit ex command line mode
Frank Fischer <frank.fischer <at> mathematik.tu-chemnitz.de>
2012-01-09 08:33:52 GMT
On Mon, Jan 09, 2012 at 02:36:56PM +0800, phay tsukiming wrote:
> Hi Frank and List:
> Evil really rocks!But i can't quit command line mode with ESC and I noticed ESC is translated into Meta. So I
use ctrl-g as a workaround instead.
> Is there an 'official' way to quit cmdline mode as VIM does?
Currently ESC does not quit ex command line. You can use backspace to
"remove" the colon which quits ex mode (if the command line is empty).
To get the behavior you desire you can try the following:
(define-key evil-ex-keymap [escape] #'abort-recursive-edit)
This allows to quit ex with the Escape-Key.
But note that this only works for X11 Emacs and not in the terminal.
The reason is that in the terminal the Escape-Key does not generate
the "escape" event but the "ESC" key-code. But the same key-code is
generated by meta-sequences like "M-x". Thus using
(define-key evil-ex-keymap (kbd "ESC") #'abort-recursive-edit)
would work in terminal mode, too, but then *no* meta sequence like
M-f, M-<right>, M-a, M-e, ... would work anymore in ex-state.
As a side information, the same problem arises with the ESC key in any
other state and Evil contains some code to handle this. But this code
is integrated in Evil's internal state and keymap mechanism and can
therefore only be used in buffers that have Evil enabled. The ex
command line is a minibuffer and (currently) Evil is never enabled in