lambdalisue / jupyter-vim-binding

Jupyter meets Vim. Vimmer will fall in love.
2.1k stars 136 forks source link

Standard vim <Esc> alternative is not set by default #124

Closed jjvliu closed 6 years ago

jjvliu commented 6 years ago

Summary

Most terminals interpret 'Ctrl-[' as 'Esc'. This is a popular way to exit from insert mode to normal mode, since you don't have to move your hand nearly as far from home row. I never have to press the physical Esc button in my workflow.

This mapping doesn't work by default for jupyter-vim-binding (at least for my browser). But it is easy to fix by explicitly defining extra keybinds for 'Ctrl-[' and 'Shift-Ctrl-['.

Environment

Behavior

In insert mode, press Ctrl-[. This should be interpreted as Esc and cause you to enter normal mode, but instead nothing happens.

Or in normal mode, press Shift-Ctrl-[. This should be interpreted as Shift-Esc and cause you to enter jupyter mode, but instead nothing happens.

What you have done to solve the issue

In vim_binding.js, copy line 71 (begins with 'Esc') and replace 'Esc' with 'Ctrl-['. Copy line 72 (begins with 'Shift-Esc') and replace 'Shift-Esc' with 'Shift-Ctrl-['.

Remarks

This keybind conflicts with a Firefox default keybind for "Go back." So we have to choose between a standard Firefox keybind and a standard vim keybind. I found another project where this issue is being talked about, and that developer decided it would be worth adopting this mapping. What do you think: should it only be mentioned as a customization option, or should it be default behavior?

jjvliu commented 6 years ago

I found a better place to define these shortcuts according to the preferred customization method (custom.js rather than vim_binding.js). I added my solution to the wiki, so this can be closed. =)