Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl-[ and Ctrl-C to exit insert mode #85

Open
axelfahy opened this issue Jun 24, 2019 · 4 comments · May be fixed by #98
Open

Ctrl-[ and Ctrl-C to exit insert mode #85

axelfahy opened this issue Jun 24, 2019 · 4 comments · May be fixed by #98

Comments

@axelfahy
Copy link

axelfahy commented Jun 24, 2019

In vim, Ctrl-[ is the equivalent of Esc and Ctrl-C quits insert mode. I think it would be nice to have the same behaviors in jupyterlab-vim.

Maybe implementing Ctrl-C is not a good idea since it will interfere with the copy shortcut. However, I think that Ctrl-[ won't interfere with other shortcuts.

Reference from vim documentation (https://vimhelp.org/insert.txt.html):

CTRL-[

<Esc> or CTRL-[ End insert or Replace mode, go back to Normal mode. Finish
abbreviation.
Note: If your key is hard to hit on your keyboard, train
yourself to use CTRL-[.
If Esc doesn't work and you are using a Mac, try CTRL-Esc.
Or disable Listening under Accessibility preferences.

CTRL-C

CTRL-C Quit insert mode, go back to Normal mode. Do not check for
abbreviations. Does not trigger the InsertLeave autocommand
event.

Update: Ctrl-[ seems to be working on Chrome but not on Firefox (v67.0.4), not sure why. (other browsers not tested)

@jwkvam
Copy link
Owner

jwkvam commented Jul 16, 2019

Interesting I didn't realize ctrl-[ wasn't working on all platforms, I typically only use chrome. I just tried Firefox and it seems like it was working for me? I check Safari and it was working there for me as well.

I'm using Firefox 68.0 (Quantum) and jupyterlab-vim 0.11.0.

@axelfahy
Copy link
Author

axelfahy commented Jul 25, 2019

Maybe it is a plugin that is capturing the key, but when I use CTRL-[, it leaves the cell instead of going to normal mode (which is annoying since I have to re-click on the cell to have the focus again).

However, if I add the keybinding in src/index.ts (as in PR #86), it works as expected.

Using Firefox 68.0.1, jupyterlab 1.0.2, jupyterlab-vim 0.11.0

@llinfeng seems to have the same issue since he said in #81 that he recompiled the plugin with CTRL-[ added in the keybindings.

@llinfeng
Copy link
Contributor

@axelfahy Were you also recompiling the plugin when you "added the keybindings in src/index.ts"? I am interested to learn a better way to simplify the following steps:

  1. Pull all the sources from Github,
  2. Insert my snippets of mappings to src\index.ts
        commands.addKeyBinding({
            selector: '.jp-Notebook.jp-mod-editMode',
            keys: ['Ctrl ['],
            command: 'leave-insert-mode'
        });
        commands.addKeyBinding({
            selector: '.jp-Notebook.jp-mod-editMode',
            keys: ['Ctrl ]'],
            command: 'notebook:enter-command-mode'
        });
  1. Compile by installing the dependencies and issuing the following commands as mentioned in the ReadMe
jlpm install
jlpm run build
jupyter labextension link .

I have compared things side-by-side across Chrome, Edge and Firefox

  • Ctrl + [ is working with all three browsers, per its newly mapped function of exiting from Insert mode to normal mode within the "editing cell";
  • Ctrl + ] is not working in Firefox, but working well in Chrome and Edge. When it is working, Ctrl + ] did get me out of the "editing cell" to manipulate all other cells in the notebook.

Raw conclusion: something is wrong with Firefox :) May need further debugging to see what captures Ctrl + ].

@axelfahy
Copy link
Author

axelfahy commented Jul 26, 2019

Yes, I recompiled the plugin after adding the keybinding. Afterwards, CTRL-[ worked fine.
I followed the same steps to compile the plugin, I haven't found a simpler way to do it.

@axelfahy axelfahy linked a pull request Oct 8, 2019 that will close this issue
4 tasks
axelfahy referenced this issue in jupyterlab-contrib/jupyterlab-vim Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants