Open danijar opened 7 years ago
I face the same problem and recognize <Ctrl-c>
as vim's default shortcut to leave insert mode. To actually manually map <Ctrl-c>
to <Esc>
I tried the following two variations within a cell:
:imap <Ctrl-c> <Esc>
:imap <C-c> <Esc>
Unfortunately this does not work. I had no problems mapping other Ctrl
shortcuts like :imap <C-o> <Esc>
. I'm not quite sure how intertwined Jupyter's cells are with IPython's interactive console, because I was able to bind <Ctrl-c>
within IPython.
How were you able to leave insert mode through <Ctrl-c>
@danijar ?
I think this may be possible using the codemirror map commands https://codemirror.net/doc/manual.html#vimapi but @flxai if you ran those commands from inside a cell there may be some strangeness in how codemirror handles them due to how the extrakeys are being set https://github.com/lambdalisue/jupyter-vim-binding/blob/c9822c753b6acad8b1084086d218eb4ce69950e9/vim_binding.js#L70-L74
Is this possible? I played around with the code a bit. What I tried is to assign a key handler to
Ctrl+C
and inside that check whether the user is currently in insert mode. In insert mode, it should leave insert mode. Otherwise, I tried to returnfalse
to get the default copying behavior, but this didn't work.Update: More generally it would be cool to be able to configure different keybindings for different modes.