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

How to use my own keyboard shortcuts when coding with notebook? #1447

Closed
honkerjha opened this issue Oct 14, 2019 · 12 comments
Closed

How to use my own keyboard shortcuts when coding with notebook? #1447

honkerjha opened this issue Oct 14, 2019 · 12 comments

Comments

@honkerjha
Copy link

I set some user shortcuts in the VSCode,but when I coding with notebook I found the shortcuts did not work. How to user my own keyboard shortcuts when coding with notebook ?
And, I set '"editor.mouseWheelZoom": true' in 'setting.json',it also doesn't work. How should I do?

@rchiodo
Copy link
Contributor

rchiodo commented Oct 15, 2019

Sorry but most of the custom editor settings do not apply yet to the Jupyter notebook editors.

They aren't being hosted inside of VS code, but inside of a separate process that uses an editor that looks a lot like VS code's. We need to port all of the functionality for VS code over to this new editor before it will work there as well.

Can you list out all of your editor customization settings? This way we can prioritize ones that people are using.

@oguimbal
Copy link

@rchiodo Hi, same for me... My key bindings alow me to almost never touch my mouse nor the arrow keys (basically, I avoid everything which makes me move my hands ...).
Thus, not having my keybindings available into jupyter is a bit frustrating. That would be supercool if they can be seemlesly integrated.

My keybindings.json file: https://pastebin.com/s8RkafPp

@xgdgsc
Copy link

xgdgsc commented Nov 29, 2019

ctrl+b for hiding sidebar not working inside notebook.

@rchiodo
Copy link
Contributor

rchiodo commented Dec 2, 2019

Sorry but most of the VS code shortcuts are not supported.

We hope to either reimplement all keyboard shortcuts (where possible) or possibly VS code will take ownership of rendering notebooks themselves (wherein a notebook would be just like any other document).

@Noezor
Copy link

Noezor commented Dec 4, 2019

That's unfortunate. I think VSCode + notebook + shortcuts would be a supreme tool for fast data-science-y projects dev speed.

@kris-steinhoff
Copy link

kris-steinhoff commented Feb 2, 2020

Related: microsoft/vscode#82495 (adding here because I found that issue first and had to do more detailed searching to get to this one)

@austinmw
Copy link

austinmw commented Mar 22, 2020

Would love to just be able to Cmd+A to Select All in a cell. Also Cmd+Shift+Arrow to select everything before or after cursor. Those ones are huge for me personally.

@pinhodb
Copy link

pinhodb commented May 14, 2020

ctrl+b for hiding sidebar not working inside notebook.

It works in edit mode for me.

@jamilraichouni
Copy link

jamilraichouni commented Jul 12, 2020

Sorry but most of the custom editor settings do not apply yet to the Jupyter notebook editors.

They aren't being hosted inside of VS code, but inside of a separate process that uses an editor that looks a lot like VS code's. We need to port all of the functionality for VS code over to this new editor before it will work there as well.

Can you list out all of your editor customization settings? This way we can prioritize ones that people are using.

I have all my Jupyter notebook keybindings in the following file ${JUPYTER_CONFIG_DIR}/custom/custom.js and it looks like listed below.

// CodeMirror API - https://codemirror.net/doc/manual.html#api


require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace", "codemirror/lib/codemirror"],
    function(sublime_keymap, cell, IPython, CodeMirror) {
        cell.Cell.options_default.cm_config.keyMap = 'sublime';

        cell.Cell.options_default.cm_config.extraKeys["Cmd-Enter"] = function(cm) {}

        cell.Cell.options_default.cm_config.extraKeys["Cmd-7"] = function (cm) {
            // Delete the part of the line before the cursor.
            CodeMirror.commands.toggleComment(cm);
        };

        cell.Cell.options_default.cm_config.extraKeys["Cmd-F7"] = function (cm) {
            // Delete the part of the line before the cursor.
            CodeMirror.commands.delLineLeft(cm);
        };

        cell.Cell.options_default.cm_config.extraKeys["Cmd-F8"] = function (cm) {
            // Delete the whole line under the cursor, including newline at the end.
            CodeMirror.commands.deleteLine(cm);
        };

        cell.Cell.options_default.cm_config.extraKeys["Cmd-F9"] = function (cm) {
            // Delete the part of the line after the cursor. If that consists only
            // of whitespace, the newline at the end of the line is also deleted.
            CodeMirror.commands.killLine(cm);
        };

        var cells = IPython.notebook.get_cells();
        for(var cl=0; cl< cells.length ; cl++){
            cells[cl].code_mirror.setOption('keyMap', 'sublime');

            cells[cl].code_mirror.setOption("extraKeys", {
                "Cmd-Enter": function(cm) {},

                "Cmd-7": function(cm) {
                    // Delete the part of the line before the cursor.
                    CodeMirror.commands.toggleComment(cm);
                },

                "Cmd-F7": function(cm) {
                    // Delete the part of the line before the cursor.
                    CodeMirror.commands.delLineLeft(cm);
                },
                "Cmd-F8": function(cm) {
                    // Delete the whole line under the cursor, including newline at the end.
                    CodeMirror.commands.deleteLine(cm);
                },
                "Cmd-F9": function(cm) {
                // Delete the part of the line after the cursor. If that consists only
                // of whitespace, the newline at the end of the line is also deleted.
                    CodeMirror.commands.killLine(cm);
                },
            });

        }
    }
);

This separate process, is a Jupyter server in the end. Does VSCode also invoke CodeMirror? If so, something like that what I'm doing here might be possible.

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@0liu
Copy link

0liu commented Jan 22, 2021

Any progress on this? Without custom keybindings inherited from vscode makes this project not much meaningful since people could do almost everything in a browser.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 23, 2021

@0liu this is actually happening soon in the VS code insiders version. See these two items:

#4438
#4376

@rchiodo
Copy link
Contributor

rchiodo commented Jan 23, 2021

Closing in favor of #4376

@rchiodo rchiodo closed this as completed Jan 23, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests