6 neat tricks for Visual Studio Code

From simple shortcuts to expert-level configuration changes, turn to these power tips to get the most out of Microsoft’s open source programming editor.

6 neat tricks for Visual Studio Code
Cerae / Getty Images

Even without the oodles of extensions that make Visual Studio Code a power tool for every developer, Microsoft’s open source programming editor is loaded with nifty features by default. However, some of these useful features are not obvious, even to seasoned users. And with each new release of VS Code, more handy features get rolled in—often remaining below the waterline.

Here we’ve listed six useful Visual Studio Code capabilities that you might not be aware of. Most will appeal to developers of all levels of VS Code expertise, from the newcomer to the seasoned vet.

Type to find any Visual Studio Code command

Want to find a command, any command, in VS Code? Press Ctrl-Shift-P and start typing. The command palette, as it’s called, gives you fast access to any registered command, including those provided by add-ons. Plus, if there’s a key binding associated with a given command, it’s displayed in the type-to-search drop-down list. This way, you can cut straight to the key shortcut in the future.

visual studio code command palette IDG

Type in the Visual Studio Code command palette to search for any command, including its key bindings.

Kick the Visual Studio Code terminal open/shut with one hand

The pop-open terminal window in VS Code is a massive convenience. No need to switch out to another application window to deal with the terminal. It’s also readily accessible by pressing Ctrl-` (the backtick key). What’s nice about this default key binding is that pressing these keys requires only one hand, so you can kick open the window or shut it without touching the mouse. Also, the focus for the cursor goes to the terminal window when you open it, so you can just kick it open and start typing.

visual studio code terminal IDG

Visual Studio Code’s integrated terminal can be opened and shut with a one-handed keystroke.

Use multiple cursors in a Visual Studio Code document

One fairly wizardly way to edit a document in VS Code is to define multiple cursors. That’s right—you can type in a document in more than one place at a time.

If you hold down the Alt key and click somewhere, you’ll put down a new cursor. Each cursor will accept the same key commands at the same time—a handy way to enter boilerplate text on multiple lines at once, for example.

Another way to add cursors is to hold Ctrl+Alt and press the up or down arrow keys. Doing so will insert cursors in the lines above or below the current one—useful for working in columns of text.

Another slick move: You can insert a cursor at every instance of a selected piece of text by hitting Ctrl-Shift-L. You can also control the selection size of multiple cursors by pressing Shift-Alt and the left or right arrow.

To go back to a single cursor, just hit the Escape key.

visual studio code cursors IDG

Visual Studio Code lets you type in multiple places in a document at once using multiple cursors.

Get word-based suggestions in Visual Studio Code from multiple documents

VS Code has the ability to make word-based suggestions as you type for most common plain-text document types. By default, however, suggestions only get supplied from the current document, or from open documents of the same type.

A recently introduced feature lets you find suggestions from all currently open files. Set the editor.wordBasedSuggestionsMode configuration option to allDocuments to get suggestions from every file that’s open, not just what you’re currently editing or open files with the same extension. This is handy if you have files that hold type stubs for your application, but don’t share a file extension with the file you’re editing.

visual studio code word based suggestions IDG

Enable word suggestions in Visual Studio Code from all open documents. The suggestion “db_context” comes from an open code file.

See Visual Studio Code’s internal process list

Operating systems have utilities, like Windows’ Task Manager, that let you see a list of the system’s currently running processes. Similarly, VS Code has its own internal Process Explorer that lets you see a list of all the subprocesses running inside the code editor—every window, extension, externally spawned process, and so on. For each process, Process Explorer displays the process ID and the CPU and memory usage.

To open Process Explorer, just select “Open Process Explorer” from the Help menu, or search for “Process Explorer” in the command palette. You can right-click on a process to copy its information or to kill it. Note that you can’t sort the view, but the process using the most memory or CPU will be highlighted.

visual studio code process explorer IDG

Visual Studio Code’s Process Explorer lets you see all of the application’s running processes including extensions.

Run Visual Studio Code as a portable application

As a rule, you’ll run Visual Studio Code as a formally installed application, just like you would full-blown Visual Studio or Microsoft Office. But there may be scenarios where it’s useful to run VS Code portably—i.e., from a removable drive, or from an odd directory on your system without formally installing it. To do this, VS Code provides Portable Mode, which is supported on the .zip/.tar.gz archived version of the application.

Note that any upgrades to a portable copy of VS Code have to be made by hand, by copying the user data from the old install to the new one. Also note that you can migrate an existing VS Code installation to portable mode, but you can only do this by copying the data directory from a formally installed VS Code version to a new copy of the portable version. You can’t “in-place” convert an installed VS Code instance to a portable edition.

Copyright © 2021 IDG Communications, Inc.