Search notes:

Visual Studio Code

Installing

VS Code can be installed with Chocolatey:
choco install -y vscode --params "/NoDesktopIcon /NoQuicklaunchIcon /NoContextMenuFiles /NoContextMenuFolders" # /DontAddToPath

Starting on the command line

code
code . Open code with current directory
code -r . Open code with current directory
code --locale=de Use specific language
code -d left.txt right.txt Compare two files in diff mode.
code -d -n left.txt right.txt Compare two files in diff mode in a new instance of code
code --goto main.cpp:20:5 Jump to given line and column in file
code --disable-extensions . Disable all extensions
code -help Summary of options
code --profile "Data Migration Prj" Launches VS Code with the specified profile
See also argv.json (for example located under %USERPROFILE%\.vscode).

Interesting keyboard shortcuts

Keyboard shurtcuts can be modified in keybindings.json. Some interesting shortcuts include:
ctrl+pageUp/pagedown Switch to next/previous window (aka pane?)
shift+alt + mouse click Column (box) selection
ctrl+, File -> Preferences -> Settings
ctrl+shift+p or F1 Command Palette
ctrl+p Go to (already opened?) files by typing parts of their names
ctrl+r Open a recently opened folder or file (Same as File -> Open Recent ?)
ctrl+b Show/hide (toggle) sidebar
ctrl+0 // ctrl+1 resp. Set focus to Side Bar, to Editor, respectively.
ctrl+k z Enter Zen mode
ctrl+k m Set language mode for current file.
ctrl+space IntelliSense
ctrl+shift+i Toggle developer tools (which displays, among others, messages written from an extension with console.log()).
See als the menus
Some of these keyboard shortcuts don't seem to work together with the VIM plugin.

Profiles

A profile stores
The menu related to profiles is found under File -> Preferences -> Profiles.
When VS Code is launched, a profile can be specified on the command line:
code --profile "Daga Migration Prj"
Profiles are stored in the user data directory under User/profiles/profile-num. profile-num is a number that does not seem to be related to the profile name.

Encoding

The default character encoding of VS Code is UTF-8 without BOM.
The default(?) encoding can be changed in VS Code settings (ctrl+,) by assigning a value to "files.encoding". Some accepted values include
It is possible to have VS Code auto detect encoding by setting "files.autoGuessEncoding": true in settings.json.

Changing a file's encoding

A file's encoding can be changed by clicking on the shown encoding in the bottom bar which opens an «action popup» where the action Save with Encoding allows to choose an enccoding for the file.

Misc

VS Code is built using web technologies on top of Electron (which apparently uses Chromium to render the user interface).

VS Code in the browser

vscode.dev is a lightweight version of VS Code running in a web browser. It uses the File System Access API, so with browsers supporting this API, local files can be edited in a browser.
Another example is github.dev which is GitHub's way to display files of repositories hosted in GitHub.
See also the extension manifiest file's (package.json) directive browser.

TODO

VS Code API

The VS Code API is a JavaScript interface that can be called from an extension.
The namespaces and functions of this API are found in vscode.d.ts.

Commands

A command is a (JavaScript?) function (sometimes referred to as command handler) that is identified by a unique identifier.
Commands are added to VS Code with either
  • ….commands.registerCommand(), or
  • ….commands.registerTextEditorCommand(…)
Then, commands are executed
  • explicitly with ….commands.executeCommand(…), or
  • triggered by so called gestures (entering commands in the Command Palette or by a bound key)

keybindings.json

[
{"key": "ctrl+shift+i", "command": "workbench.action.toggleDevTools" /* Help -> Toggle Developer Tools. Override when clause (isDeveloper) */ }
]

Extension dependencies on tsc (TypeSript compiler)

Some extensions seem to be dependent on a TypeScript compiler (tsc).

PATH environment variable, installation directory, bin

At least on Windows, there is an executable named Code.exe in the installation directory and one in its \bin directory.
The PATH environment variable should be set to the executable in the \bin directory in order be able to start VS code from the command line. If PATH points to the other executable, Code can be started, but some strange things are happening then.

See also

workspace
settings.json
Text editors

Index