My JupyterLab version is 3.5.0. I want the shortcuts to be similar with vscode, and customize them at the following path (on Mac)
~/.jupyter/lab/user-settings/#jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings
but each time reopen JupyterLab, this file shortcuts.jupyterlab-settings will be overwritten, and the disabled shortcuts will be added back automatically.
For example, the disabled key
"command": "notebook:change-cell-to-markdown",
"keys": [
"M"
],
"selector": ".jp-Notebook:focus",
"disabled": true
},
will be replaced by
{
"args": {},
"command": "notebook:change-cell-to-markdown",
"keys": [
"M"
],
"selector": ".jp-Notebook:focus"
},
The following screenshot shows the differences: the LHS is my settings, and the RHS is the file shortcuts.jupyterlab-settings overwritten by JupyterLab.
How to prevent this behaviour?
Related
I'm very used to IntelliJ IDEA's family keybinding (PyCharm, WebStorm, RubyMine...).
How can I configure Sumblime Text 3 to use those shortcuts?
I've been googling and I can't find anything! But I don't think I'm the only one needing this. Thank you :)
Sublime Text 3 - User Key Bindings (IntelliJ IDEA Style) - Windows
[
{ "keys": ["ctrl+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+d"], "command": "duplicate_line" },
{ "keys": ["shift+alt+up"], "command": "swap_line_up" },
{ "keys": ["shift+alt+down"], "command": "swap_line_down" }
]
found the answer here.
Following the instruction to create custom shortcuts in Jupyter Lab, I've got the hide and show work but not the one to clear cell output (the first command entry). Does anyone know what the issue is? Thank you!
{
"shortcuts": [
{
"command": "notebook:clear-cell-outputs",
"keys": [
"Ctrl L"
],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:hide-cell-outputs",
"keys": [
"O"
],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:show-cell-outputs",
"keys": [
"Shift O"
],
"selector": ".jp-Notebook:focus"
}
]
}
The correct command to use is notebook:clear-cell-output (no "s" at the end). The complete command list can be found here.
I am using Sublime Text 3, and I installed JSFormat to format my .js files and configured the key binding like this:
{ "keys": ["ctrl+shift+f"], "command": "js_format" }
Now, I also want to be able to format my .css and .html files, so I found this shortcut:
{ "keys": ["ctrl+shift+f"], "command": "reindent" , "args": { "single_line": false } }
I want to use js_format for my .js files and use reindent for my .css and .html files.
Is it possible to specify a file type per shortcut?
Update
This apparently no longer works in Sublime Text 4.
Update
I've since discovered that this is a duplicate of Sublime Text 3: how to bind a shortcut to a specific file extension?
Original Answer
Add a context:
{
"keys": ["ctrl+shift+f"],
"command": "js_format",
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "source.js"
}
]
}
The important part is setting operand to source.js. You can replace js with whatever file extension you want. You can also specify additional sources with commas. For example, this would cause a command to apply to all .html and .css files:
{ "key": "selector", "operator": "equal", "operand": "source.html, source.css" }
See the unofficial documentation on key bindings.
I have added following piece of code to Preferences > Key Bindings - User configruation file in my Sublime Text 3:
{ "keys": ["ctrl+b"], "command": "insert_snippet", "args": {"contents": "<strong>${0:$SELECTION}</strong>"} },
As a result, when user presses Ctrl+B in editor, current selection is surrounded with HTML tags <strong> and <strong>.
Is there anyway, I can make this setting file-type depended? I.e. if user is working in *.txt or *.md file, then pressing Ctrl+B in editor should surround selection with Markdown bold tag (**) and, when editing any other type of file (in general or *.html files in particular), then to surround with HTML tags, as in above example.
Is this possible in Sublime Text 3?
This can be done with the context parameter:
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "source.php"
}
]
selector Returns the name of the current scope.
operator Type of test to perform against key‘s value. Defaults to equal.
operand The result returned by key is tested against this value.
More help see: http://docs.sublimetext.info/en/latest/reference/key_bindings.html
Examples
For recognizing Ctrl+B in HTML only
// bold snippet for html
{
"keys": ["ctrl+b"],
"command": "insert_snippet",
"args": {"contents": "<strong>${0:$SELECTION}</strong>"},
"context": [
{"key": "selector", "operator": "equal", "operand": "text.html.basic"}
]
},
For recognizing Ctrl+B in Markdown and plain text:
// bold snippet for markdown and plain text
{
"keys": ["ctrl+b"],
"command": "insert_snippet",
"args": {"contents": "**${0:$SELECTION}**"},
"context": [
{"key": "selector", "operator": "equal", "operand": "(text.html.markdown, text.plain)"}
]
},
I've got both Leiningen & Clojure working on Windows 8 separately from Sublime Text (e.g. I can get a repl working in Windows PowerShell).
My problem is that I can't get the SublimeREPL working in SublimeText (the REPL loads up but doesn't then do anything). Are there any simple traps that I might be missing or, failing that, are there a series of steps I could follow to troubleshoot?
Please see this SublimeREPL issue for instructions on how I got a Clojure REPL to work, at least on XP (I haven't tried it on Win7 or 8 yet). Basically, I edited the menu file for Clojure, and changed the command from lein repl to lein trampoline run -m clojure.main, which for some reason did the trick. I also changed the path to $file so you can open up a REPL while your project.clj is the current tab in Sublime, and the REPL should inherit the project's settings.
For reference, the complete Packages/User/SublimeREPL/config/Clojure/Main.sublime-menu file (Packages is accessible via Preferences -> Browse Packages...) is as follows:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Clojure",
"id": "Clojure",
"children":[
{"command": "repl_open",
"caption": "Clojure Trampoline",
"id": "repl_clojure",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": {"windows": ["lein.bat", "trampoline", "run", "-m", "clojure.main"],
"linux": ["lein", "repl"],
"osx": ["lein", "repl"]},
"soft_quit": "\n(. System exit 0)\n",
"cwd": {"windows":"$file_path",
"linux": "$file_path",
"osx": "$file_path"},
"syntax": "Packages/Clojure/Clojure.tmLanguage",
"external_id": "clojure",
"extend_env": {"INSIDE_EMACS": "1"}
}
},
{"command": "clojure_auto_telnet_repl",
"id": "repl_clojure_telnet",
"caption": "Clojure-Telnet"}]}
]
}]
}
]
I solved this problem with Git Bash Shell. I have used the shell script version of leiningen instead of lein.bat
This is the command I use:
["C:\\Program Files\\Git\\bin\\sh.exe", "-l", "--", "/d/lein.sh", "repl"]
assuming lein.sh is in d:\
lein trampoline command sometimes behaves differently from lein repl and could fail due to unknown reasons.