I'm trying to set 3 keyboards shortcuts in jupyterlab. I go about this via settings / advanced settings editor / keyboard shortcuts, that's the only method I'm aware of.
I'm trying to set:
notebook:run-all-cells
notebook:run-all-above
notebook:run-all-below
I've experimented with the selectors that work for restart-and-clear: "selector": "[data-jp-kernel-user]:focus" and several others, not really understanding what they were to be honest, but I couldn't get it to work. Can someone tell me which selector I need to use here? How does one go about figuring this out?
Thanks
Since you are trying to run cells, presumably having one of the cells selected, I would use [data-jp-code-runner], for example:
{
"command": "notebook:run-all-cells",
"keys": ["F9"],
"selector": "[data-jp-code-runner]"
}
To discover a selector in the future you can search the list of existing shortcuts in the left panel. for example searching for Shift Enter or run keyword brings up:
{
"command": "runmenu:run",
"keys": [
"Shift Enter"
],
"selector": "[data-jp-code-runner]"
},
Alternatively you could:
use just body if you want the shortcut to be always active (even though it may error if executed when focus is not on appropriate element)
(advanced) use web developer inspector tool in your browser to determine the web query (CSS) selector for the element of interest
I would like to switch between windows (vscode) regardless if the focus is on the editor or on (any) terminal. I tried the key binding below in the json file without any luck. Also, dropping the "when" clause or only using terminalFocus doesn't work. It seems I can only switch windows if the focus is on the editor. Would be grateful for any suggestions.
{
"key": "ctrl+w",
"command": "workbench.action.switchWindow",
"when": "terminalFocus || editorTextFocus"
}
In my testing I see two options:
(1) It appears that any other keybinding except Ctrl+W works as expected; or
(2) add your command workbench.action.switchWindow to the Terminal > Integrated: Commands to Skip Shell list in your settings if you want to use Ctrl+W as your keybinding.
When I press Cmd + Shift + E I set focus on the explore file tree, and can now navigate my files with the arrow keys.
Enter should active the file but instead it activates the rename command that is normal associate with F2.
It works on windows but not on my macbook. I know how to create a custom key binding. but I can not find the command for activating a file in keybindings.json.
I am using Parallels Desktop 12 for Mac and know that it can cause keyboard binding issues. But I dont think it's the case here.
So do someone have a solution for this or know the command to activate in the keybindings.json file?
Bind the list.select event to enter in your keybindings.json
{
"key": "enter",
"command": "list.select",
"when": "listFocus"
}
I'm using VSCode as my text editor. I'm curious, is there a keybinding for centering the editor window on the cursor, when the window is a lot of lines below/above it such that it's not visible on the screen? I've tried looking at the default keybindings by going to FIle > Preferences > Keyboard Shortcuts, but I see no such options for centering the window.
There is no such keybinding / command built-in.
I couldn't stand that either, so I created a VSCode extension. You can find it and install it here on the marketplace. The default shortcut is CTRL + L.
If you are using vscodevim, zz should work.
If you want to always keep the cursor on the center, you can change the setting Cursor Surrounding Lines to a really high number (100 is ok) and that should work.
As #kwood put it, there is an extension Center Editor Window in the marketplace that meets this end.
I would like to make an answer here, to complement that -- even the extension's author did not explicitly state in the marketplace page -- if you would like to change the default key binding (Ctrl+L), you may try put the following lines in the keybindings.json for the keyboard bindings.
{
"key": "cmd+k cmd+c",
"command": "center-editor-window.center",
"when": "editorTextFocus"
},
The above command sets ⌘ Command+K, ⌘ Command+C as the keyboard shortcut.
Apart from that, you may set
"center-editor-window.threeStateToggle": true,
in the settings.json for VS Code settings so that it will switch among three states (center, top, bottom) instead of one (center).
I have to write some code in ML and it is my first time I`m going to use the language.
Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers for Linux (at most with an interactive console), but no IDE nor Eclipse/NetBeans plugin.
Any suggestions ?
How to Configure SML with Sublime Text 2
For those who prefer Sublime Text instead of Emacs as the editor of choice to program SML, the following guide describes how to configure Sublime Text to work with SML.
For this guide to work for you, you must already have installed smlnj.
Step 1: Install Sublime Text and Package Control
Start by Downloading Sublime Text 2. Make sure to download version 2, because the SML syntax support does not yet work with version 3.
Sublime Text supports an amazing set of packages (i.e. plugins) that you can install separately. One of those packages is called Package Control. You must first Install Package Control to be able to install other packages directly from the editor. The provided link explains what you need to do to install this package.
Step 2: Install SML and Sublime REPL
Now that you have Package Control installed it is going to be really easy to install other packages. There are two packages that we must install now: SML to support syntax highlighting features for the programming language and SublimeREPL which, as you might guess, is a package that adds REPL capabilities for many different programming languages to Sublime Text.
To install these packages you must go to the menu and look for Tools -> Command Palette and type "Install Package". In the search box, you write the name of the package you want to install, select your package from the found list, and hit enter to get it installed. Do this for the two packages mentioned above: "SML" and "SublimeREPL"
Once you have installed the SML package, if you open an SML file you should get syntax highlight capabilities within the editor. It even provides a Sublime Text Theme called Son of Obsidian that you could enable in Preferences -> Color Scheme -> SML -> Son of Obsidian. But you are not required to enable the theme to work with SML, this is just a preference.
Once you have installed the SublimeREPL package you will be able to go to the menu Tools -> SublimeREPL -> SML and open an SML REPL session that will support syntax highlight using the SML package, and command history, line editing and autocompletion. You can make your life really easy if you open two side by side tabs and in your left tab you can have your SML code file and in your right, you SML REPL session. You can do that by using the View -> Layout options.
Step 3: Keyboard Shortcuts
Now let's add a few keyboard shortcuts to work with the REPL. The SublimeREPL package offers little keyboard configuration, and the ones provided are probably not going to work well with the SML REPL. So this is what I typically do.
First go to Preferences -> Browse Packages
Go into the SublimeREPL/config/SML subfolder.
Edit the file Default.sublime-commands in Sublime Text itself. This file contains the current SML menu options within the Tools -> SublimeREPL menu. So, we'll now change it to create a second option that can run an existing file in a new SML REPL session. My edited file looks as shown below. Notice the "id" field. We can define as many different commands as we want, giving them a different ID. In the next step, we'll define what every command does.
[
{
"caption": "SublimeREPL: SML",
"command": "run_existing_window_command", "args":
{
"id": "repl_sml",
"file": "config/SML/Main.sublime-menu"
}
},
{
"caption": "SublimeREPL: SML - Run File",
"command": "run_existing_window_command", "args":
{
"id": "repl_sml_run",
"file": "config/SML/Main.sublime-menu"
}
}
]
Now, in the same directory as the previous file, edit the Main.sublime-menu file. This file contains the details of what every command defined above should do. My edited file defines the two commands described above, one to simply open the REPL and one to open the current file in the REPL. It looks as follows:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[{
"caption": "SML",
"id": "SML",
"children": [
{"command": "repl_open",
"caption": "SML",
"id": "repl_sml",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["sml"],
"cwd": "$file_path",
"external_id": "sml",
"syntax": "Packages/SML (Standard ML)/sml.tmLanguage"
}
},
{"command": "repl_open",
"caption": "SML - Run Current File",
"id": "repl_sml_run",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["sml", "$file_basename"],
"cwd": "$file_path",
"external_id": "sml",
"syntax": "Packages/SML (Standard ML)/sml.tmLanguage"
}
}
]
}]
}]
}
]
The final step is to add keyboard shortcuts for this two commands. Go to Preferences -> Key Bindings User and edit the file with the following two additional commands. Feel free to change my keys and use whatever other shortcut keys you find appropriate, provided they are not used for other features.
[
{
"keys":["ctrl+alt+j","k"],
"command": "repl_open",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["sml"],
"cwd": "$file_path",
"syntax": "Packages/SML (Standard ML)/sml.tmLanguage",
"external_id": "sml"
}
} ,
{
"keys":["ctrl+alt+j","m"],
"command": "repl_open",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["sml", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/SML (Standard ML)/sml.tmLanguage",
"external_id": "sml"
}
}
]
And we're done. Now, you can open the SML REPL by simply pressing CTRL+J,K (this is press Ctrl+Alt+J, then release keys and press K). And if you are currently working in an SML file, you can press CTRL+J,M to send it to a new SML REPL session.
Step 4: Build System
Sublime Text provides configurations that allow you to parse your code file and determine if something is wrong and let you know exactly where the problem is. In order to do this, we must configure a "build system". The configuration is simply a file that tells sublime text what command to run and how to interpret the output. If sml parser gets to fail to parse or execute your program then the output tells you where the problem is. The build system lets us define a regular expression to parse such output and help Sublime text find the line and column that contains the problem.
Go to Preferences -> Browse Packages and under the User folder create a new file named SML.sublime-build and define the file as follows:
{
"cmd": ["/usr/local/bin/sml","$file"],
"selector": "source.sml",
"working_dir": "$file_path",
"file_regex": "^(.*\\.sml):(\\d+)\\.(\\d+)(\\-(\\d+)\\.(\\d+))?\\s(.*)$"
}
Make sure to replace the command path with a valid path in your system. Once you have saved the file, you can go to the menu and choose Tools -> Build System -> SML. Then, to check your file, you can do Tools -> Build to parse your file and find any errors. And by using the menu option Tools -> Build Result -> Next Result and Previous Result you can navigate between the errors detected by the build system option and Sublime Text will position the cursor in the exact position of the error as reported by the SML compiler.
My regular expression above might not be the best, so feel free to improve it as you see fit.
And that's it. You're pretty much ready to start coding with SML and Sublime Text.
You can use Isabelle/jEdit as IDE for Isabelle/ML or official Standard ML (SML'97). The underlying ML system is Poly/ML, which is notable for its support for multicore-hardware.
Strictly speaking the Isabelle environment is for interactive and automated theorem proving, but its SML IDE support is quite sophisticated: source files are statically checked and semantically evaluated while the user is editing. The annotated sources contain markup about inferred types, references to defining positions of items etc.
As a quick start, see the Documentation panel, section Examples, entry src/Tools/SML/Examples.thy (as of Isabelle2014).
When working with SML on Windows, I've been using SML/NJ for compiling and Notepad++ for editing (Notepad++ has syntax coloring for Caml, which should be identical to SML for your needs).
As mentioned, for ML a simple editor should be enough.
For SML a few Emacs modes exist. Check http://mlton.org/Emacs for more information.
The sml-mode should provide you a good environment for writing SML code. Eclipse & Co. were developed due to the fact that java requires a lot of boilerplate stuff like accessors, adapters and so on. If you require same features for ML then you should double-check whether you are not over-engineering.
Edit: and by the way, SMLNJ ships with an eclipse plugin. I can't post a link though, just google for smlnj eclipse .
I'm developing Scheme IDE for Windows. It's called "Babbage" . It has also mode for OCaml and SML. It is like a minimum Emacs. Babbage is very simple and has windows like key assign. Babbage is Unicode editor.
http://homepage1.nifty.com/~skz/Entry/babbage.html
Eclipse can be set up to get much useful functionality, without having an sophisticated specific language plug-in.
I maintain a guide for setting up Eclipse for new languages. Some highlights from that document:
Syntax colors can be added with either the Eclipse Colorer. They are plug-ins that provides syntax colors for a large number of languages, including SML and OCaml. New languages can be added easily using custom color files.
To build using an external compiler from inside Eclipse the standard Program Builder feature can be used. The builder is run when the normal Build Project command is issued. To set up a new builder: Project Properties -> Builders -> New... -> Program or use the Laid Build Marker plug-in below.
To capture compile errors and warning from an external builder a build output parser can be used. Laid Builder Marker is a plug-in that implements such parsers. The parsers put problem markers in editors and in the Problems view. This plug-in can also be used to add Program Builders to projects. The builder for Cabal can be used as a starting point.
To run compiled programs from inside Eclipse the use the External Tools feature. (Run -> External Tools)
Extended support for code navigation and text selection can be added with some of the other Laid Project plug-ins: The Marker Block Selection plug-in can be used to select text enclosed be brackets. The Editor Utilities plug-in can be used to, among other things, jump between blocks of code delimited by blank lines.
Use the standard Word Completion command (Shift+Alt+7) as a poor person's content assist.
Use the standard Toggle Block Selection command (Shift+Alt+A) to insert/remove line comments on multiple lines at the same time.
Some other useful standard Eclipse features include:
The Open Resource command (Ctrl+Shift+R)
The File Search command (Ctrl+H)
The Bookmarks feature (Edit -> Add Bookmark). Make sure to check Include in next/prev navigation box (Preferences -> General -> Editors -> Text Editors -> Annotations -> Bookmarks).
Update site for the Laid project:
https://bitbucket.org/lii/laid_language_tools/src/master/se.lidestrom.laid.update_site/
Update site for Eclipse Colorer:
http://colorer.sourceforge.net/eclipsecolorer/
Disclaimer: I am the author of the Laid project.