How do I add a custom shortcut from the kernelmenu that uses the restart and run up to selected cell button?
I looked at another shortcut in the menu from the JSON Settings Editor and found one also using the kernelmenu. I added this shortcut below using that as my “template”.
This did not work.
Is it the selector, data-jp-kernel-user? Does it need to be data-jp-kernel something?
{
“args”: {},
“command”: “kernelmenu:restart-and-run-up-to-selected-cell”,
“keys”: [
“Ctrl Shift J”
],
“selector”: “[data-jp-kernel-user]:focus”
}
Related
In a Jupyter Notebook I can click on Help -> Edit Keyboard Shortcuts to change Command Mode shortcuts. However, I don't see how I can change Edit Mode shortcuts. How can I do this?
You are correct that Help -> Edit Keyboard Shortcuts will only change Command Mode shortcuts (at least as of Nov 2020). In fact, at the bottom of the edit keyboard shortcuts modal for Jupyter Notebook it states "Changing the keybindings of edit mode is not currently available."
So to get to the "edit" shortcuts I had to go into the notebook config. Documentation here: https://jupyter-notebook.readthedocs.io/en/stable/extending/keymaps.html
For me, the notebook config was located here "~/.jupyter/nbconfig/notebook.json". Once there, you can bind (set new shortcuts) or unbind (remove existing shortcuts).
Here is the structure of my notebook.json file:
{
"Cell": {
"cm_config": {
"lineNumbers": false
}
},
"keys": {
"command": {
"bind": {
"ctrl-enter": "jupyter-notebook:run-cell"
}
},
"edit": {
"bind": {
"ctrl-enter": "jupyter-notebook:run-cell"
}
}
}
}
Notice how I want to run cells with Ctrl-enter rather than Cmd-enter, so I am binding Ctrl-enter to run cells in command mode and edit mode. I'm on a Mac but have previously gotten used to Ctrl-enter to run cells, so I wanted to change things back.
Once you have modified your notebook.json file, restart Jupyter Notebook and your shortcuts should work!
If you are wondering where to find the code syntax name for each action, there is a command palette (tiny keyboard at the top middle right of Jupyter Notebook). After you click into it, hover over the command mode key on the right side and it will give you a little tooltip with the code syntax name.
I develop a package, which allows user to use Home button to toggle cursor position in soft-wrapped lines, as it is in Komodo Edit editor.
In my toggle() function I try to get active text editor from Atom Workspace using getActiveTextEditor function and then I do my logic.
atom.workspace.getActiveTextEditor()
I bind a Home key with a selector atom-text-editor.editor, and it mainly works fine until triggered inside Search&Replace pane or Command Palette.
"atom-text-editor.editor": {
"home": "toggle-home:toggle"
}
In this case, getActiveTextEditor returns always a currently edited file's text editor. It leads to a situation, when a cursor is moved inside an edited file's pane, but not inside focused field. When I use a Home inside a text field in Settings pane, Atom throws an exception, as it can't find any active text editor.
I did a research through Atom Docs, Atom API, even community packages, but all I found, was adding 'mini' to my event selector, to narrow event scope a bit.
"atom-text-editor.editor:not([mini])": {
"home": "toggle-home:toggle"
}
Nevertheless it still causes exception or misbehaviour in text fields without 'mini' (ie. textarea of Git/GitHub package).
What I want to achieve is:
1) to find a proper keybinding selector, that would fire only inside currently edited file pane;
OR
2) to find a method to get focused instance (Search&Replace, Command Palette or any other field) for further processing.
Solution
As DamnedScholar mentioned here:
the selector atom-workspace-axis.vertical atom-pane-container atom-text-editor:not([mini]) will do it.
Already tested, works fine.
Is there a way to mark a cell in the ipython/jupyter notebook readonly using the json format in the ipynb file? (E.g., a cell attribute "readonly":false or some such.) If not, is there a jquery hack to find suppress the double click event in the cell?
#Richard Ackon's answer requires adjustments for JupyterLab:
Open the Property Inspector.
Focus the cell you want to lock.
Add the following lines to the Cell Metadata:
{
"trusted": true,
"editable": false,
"deletable": false
}
Click on the tick to save the metadata... Tadah!, your cell can't be modified or deleted.
The Property Inspector comes built-in since JupyterLab 2.0 (note it was moved to the right sidebar by default in JupyterLab 3.0). For older JupyterLab versions you would need to modify the notebook file manually.
Unfortunately, the outputs can still be cleared by intentionally selecting that option in the menu bar (Edit > Clear Ouputs). Of course that can only happen if you DO WANT to clear the outputs and not just update them by running the cell.
Source
Yes, Use the steps below:
Select view on the menubar
Point to Cell Toolbar and select Edit Metadata
An "Edit Metadata" button will appear at the top-right corner of the cell.
Click on that button and edit the json that pops up. Set the editable key to true or false to get the desired effect.
The JSON will look something like this:
{
"deletable": false,
"editable": false,
"scrolled": true,
"trusted": true
}
There is an extension for IPython that is supposed to that:
Read Only Cell extension.
Getting it to work is something else, but it is there.
I have a an Grid with a column that must be a checkcolumn, i use this code
there are two rows in the grid but the checkcolumn looks empty. When i click on the checkcolumn the console.log returns correctly the changed boolean. But i see nothing in that column.
xtype: 'checkcolumn',
header: 'REDACTEUR',
dataIndex: 'REDACTEUR',
width: 75,
editor: {
xtype: 'checkbox'
},
renderer : function(value) {
console.log(value);
you have to manually include the css for the checkcolumn xtype like this:<link rel="stylesheet" type="text/css" href="/extjs4/examples/ux/css/CheckHeader.css">
if your app is generated by Sencha CMD, you need to execute the following command on your project directory
sencha app build
after this command has finished, reload your app on your browser and you can now see your checkcolumn.
extra js file is needed, try to seek Ext file named 'CheckColumn.js' and included it in your script. Or set the Ext's ux path at the beginning of the script also works.
I solved my disappearing checkbox/radio CSS problem in ExtJs 6.01 by running 2 commands:
1) sencha app build development
2) sencha app refresh
Refresh was important
The regular way (typing the shortcut followed by the Tab key) doesn't seem to work. If not, maybe there's some other way of inserting snippets not using the mouse, with as few keystrokes as possible? What language should be specified in the "language" attribute of the "Code" element in the .snippet file? I use VS2010.
To get the snippet menu you can use CTRL+K, CTRL+X then select the snippet you want. I don't have any problem using shortcut followed by TAB so it could be a change to your settings that is stopping it. As far as language goes the snippet menu shows snippets based on the language of your code file. You may find it useful to use a snippet editor like Snippet Editor if you are creating your own snippets.
I found out today that pressing TAB twice works OK if I type the snippet shortcut after the new keyword, so I changed the snippet code from "new AjaxOptions {UpdateTargetId = "page", OnFailure = "handleFailure", ... }" to "AjaxOptions {UpdateTargetId = "page", OnFailure = "handleFailure", ... }", and everything seems to work fine now.