# 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? IDK, don't care enough to ever find out.

Anyway, VS Code is pretty good, it turns out.

# Important keyboard shortcuts

Tab switching is not obvious. There are a lot of tweaks you could do byt 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" } } ]  # Needful extensions ## 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 Preview Enhanced, which is not perfect, but the cons are less irritationg I could possibly fix this using CSS? But I have already burned my time budget on this. ### Option 1: native markdown + mdmath You can augment native markdown preview with maths support via mdmath. Pros: • Renders math faster using KaTeX • well integrated with everything else Cons: • brackets-as-delimiters ~~doesn't work~~ UPDATE: now it does. • mdmath KaTeX macro support is quirky, as KaTeX macro support is in turn quirky. • Default markdown preview renders text full-justified, which is unreadable. (No-one else has this problem, so I have some funky CSS that I can't find, I suppose.) ### Option 2: Markdown preview enhanced Replace native markdown preview with the revamped Markdown Preview Enhanced. Pros: • Just works • supports MathJax and hence macros Cons (at least when using Mathjax): • Slow, 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. To use it a pair of Dictionary (.dic) and Affixes (.aff) files with UTF-8 encoding have to be downloaded … and placed in Dictionaries subfolder of VSCode's user global configuration directory, located at $HOME/.config/Code/Dictionaries/.

Hunspell dictionaries are not obvious, entailing e.g. character set weirdness. You can create your own. More usefully for most of us, can create your own user dictionary, or add to it using hunspell commands but it's not clear to me if VS Code will pick these up.

# Various config one needs

You config is in a JSON file, which is quaintly retro but does mean that 3rd party config is at least not purely abysmal. The path location is the following:

• Windows %APPDATA%\Code\User\settings.json
• Mac ~/Library/Application Support/Code/User/settings.json
• Linux ~/.config/Code/User/settings.json

But you can coordinate across OSes by using settings sync.

## Hover/tooltip/hint/autocompletion things are too intrusive

There are a lot of features which huddle under the opaque umbrella of intellisense, because they let someone in marketing get too near the product. But they all need tweaking, so you have to work out which is which. First, which is hover, which is hints etc? At least it's less overhead than learning elisp.

The thing that appears when you mouse over a character is hover. It probably does something useful in statically-typed languages, but ends up just being annoying in, e.g. javascript/python.

You want

    "editor.hover.delay": 3000,


so it activates after 3 seconds instead of RIGHT NOW LOOK AT ME OH SORRY WERE YOU TRYING TO READ SOMETHING ON THE SCREEN.

Possibly also

    "editor.hover.sticky": false,


The hints are probably also being annoying, right? because instead of letting you finish a line it wants to to insert some wacky argument?

    "editor.acceptSuggestionOnEnter": false,


That can be toned down by language for e.g. markdown.

How about bracket closing? (brrrrr) If you are like me and you are offended by every implementation of bracket closing you have yet seen, you want, in your config:

    "editor.autoClosingBrackets": false,


Aaaaahhhh that's better.

Alternatively, you might want to use AI-assisted IntelliSense.

## Outline view in python is mostly imports

If you are using the (deprecated) code outline extension, Alex Gvozden's solution:

    "symbolOutline.topLevel": [
"Class",
"Module",
"Constructor",
"Function",
"Method"
]


## Which language is that file?

    "files.associations": {
"*.thor": "ruby",
"*.jsx": "javascript"
}


## Privacy

    "telemetry.enableTelemetry": false


# Jupyter

You can use VS Code as an alternative client to talk to jupyter kernels

# Bonus gotchas

## Command line not working

You want it to work from the command line for fish shell on OSX?

set -U fish_user_paths \
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin" \
\$fish_user_paths


## 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