Visual Studio Code

Atom for finite time

VS Code is Microsoft’s competitor to Atom, with a similar technology stack, but somewhat cleaner and faster.

I am not clear on its relationship to the flabby Visual Studio. Some shared branding without any particular shared code? I don’t care enough to ever find out.[^“Flabby” in the sense of being busy with features I don’t want, not in the sense of wasting hard disk space and RAM. As a javascript desktop app VS Code is a gigantic RAM waster, like all the other javascript apps.]

Anyway, VS Code is OK, it turns out.

Important keyboard shortcuts

Tab switching is not obvious. There are a lot of tweaks you could do, but short story

Ctrl PageDown (Windows) or ⌘ ⌥ → (Mac).

Snippets

Roll your own snippets. You invoke them using Ctrl space <prefix> tab, where you get to define <prefix>.

Here is a example set that works good for markdown math

{
"Inline_Math": {
"prefix": "", "scope": "markdown,latex", "body": [ "\$$1\$$", ], "description": "inline math" }, "Display_Math": { "prefix": "", "scope": "markdown,latex", "body": [ "\$", "1", "\$", ], "description": "display math" }, "Display_Math_Markdown": { "prefix": "align", "scope": "markdown", "body": [ "\\\begin{aligned}", "1&=2\\\\", "\\end{aligned}\", ], "description": "display math" } } Or for a short-ish snippet you can assign direct keyboard shortcuts in the keybindings.json file (Preferences: Open Keyboard Shortcuts File) [ { "key": "ctrl+shift+4", "command": "editor.action.insertSnippet", "when": "editorTextFocus", "args": { "snippet": "\$$1\$$0" } }, { "key": "cmd+shift+4", "command": "editor.action.insertSnippet", "when": "editorTextFocus", "args": { "snippet": "\$$1\$$0" } } ] Searching and selecting Almost obvious but to get maximum value you have to learn a couple of extra things. Mutliline search expressions require you to type ⇧-⏎/Shift-Enter. That’s for vanilla string matching. For regex matching if you want to match multiline search you need to explicitly add newline characters to your character classes, i.e. [\s\S\r]+. To replace regex groups you do the usual thing - 1 is the first group etc and  is a dollar sign. Putting this together, if you wish to replace latex bracket syntax with latex dollar syntax, you replace \\$*([\s\S\r]+?) *\\$ with 1.

VS code does ordinary javascript regex. If you want fancy lookaround or backref you can enable the setting search.usePCRE2.

Multi cursors interact with search usefully. General multiple cursors are made by Alt+Click/ Option+click. There are many keyboard shortcuts to use them to automate menial chores.

Needful extensions

“Remote” editing

Remote edits code in particular environments - including spinning up containers or SSH sessions, so that your editor and execution environments can be different. The remotes in the former case can be local “remotes”.

Markdown mathematics

It comes with a built-in markdown preview, but you want mathematics support, no? Yeah you do.

You can make Markdown more legible with dark themes by using Markdown Theme Kit, bitbucket styles or github styles.

I personally use Markdown + Math, which is far from perfect, but the cons are not showstoppers. Choose your poison.

Option 1: native “Markdown + Math”

You can augment native markdown preview with maths support via Markdown + Math a.k.a. mdmath.

Pros:

• Renders math faster using KaTeX
• well integrated with everything else

Cons:

• brackets-as-delimiters doesn’t work UPDATE: it now works!
• mdmath KaTeX macro support is quirky, as the underlying KaTeX macro support is in turn quirky. Further, to detect macro updates you need to close and open the window again.
• the parser is bad at identifying delimiters – in particular

• there must be a blank line before display math and some kind of whitespace after it. This one is bad—it means that if you generate LaTeX from the markdown, there will be semantically-incorrect paragraphs before each equation. This might be a dealbreaker for you.
• No newlines in inline math (bad but survivable)
• No spaces between delimiter and math (ok)

Option 2: Markdown preview enhanced

Replace native markdown preview with the revamped Markdown Preview Enhanced.

Pros:

• Just works
• Supports MathJax and hence LaTeX-native macros

Cons (at least when using MathJax):

• Slow, presumably due to MathJax being slow
• leaks RAM
• eventually crashes

Spell checking

Spellright seems to be the best one, in terms of being fast and well-integrated into the OS. Developer Bartosz Antosik is incredibly responsive. I should send him money.

It is too aggressive with spellchecking latex maths in markdown documents. Here is a workaround I whipped up, to put in the settings file:

    "spellright.ignoreRegExpsByClass": {
"markdown": [
"\\\\\\w+"
]
}

Pro-tip: make sure that your spelling language is set to a supported dictionary, or you will miss things.

Linux and spellright

On Ubuntu you need hunspell dictionaries installed. NB it is not sufficient to install hunspell; you need to download or link the files into the right place for the extension to find them, in the correct character encoding.

Go to symbol doesn’t work

Go to definition? Go to symbol? idk; there are a lot of similar features here for code navigation It turns out go to symbol is somewhat broken generally, and totally arsed for python.

Bookmarks

Bookmarks extension