Top-Ten Productivity Tips for Visual Studio Code

By Focusoncode June 21, 2018

Over the last few years, Visual Studio Code has executed a shock-and-awe campaign over the open-source IDE market. VS Code was released publicly in 2015 and is now used
by 35% of all developers according to the 2018 Stack Overflow survey. Here are several essential Visual Studio Code tips that you should learn if you want to boost your productivity and workflow to the next level.


1.  Command Palette

Much like Sublime Text (and TextMate before it), VS Code has something called a command palette. This feature lets you access various commands just by typing them out rather than being forced to navigate menus using your mouse.

You can open up the command palette with the Ctrl + Shift + P keyboard shortcut. Just start typing what you want to do (e.g. “close”) and the options will update in real-time. Some commands are categorized, so you can use that to locate commands that you can’t seem to find.


2. Go to Definition

When you’re programming or scripting, often times you’ll run into a variable or method that you don’t recognize. So what do you do? You could spend several minutes searching for the right file, or you could select the variable/method with your cursor and hit F12 to immediately jump to its definition.

Or you can use the Alt + F12 keyboard shortcut to simply peek at the definition, which shows you the definition right in line where your cursor is rather than opening up the source file.



3. View Multiple Files at Once

Most modern text editors can support multiple files at once, allowing you to switch between open files through some kind of tab-based interface. More advanced text editors may even support side-by-side text editing, which VS Code does (albeit horizontally only). But side-by-side editing is tough on smaller screens, whether that means on a laptop or an older monitor—and that’s where VS Code shines.


4. Edit Multiple Lines at Once

If you ever need to insert or delete multiple instances of text throughout a document, all you have to do is create multiple cursors. You can do this by holding down Alt (or Option on Mac) and clicking anywhere in the text. Every click creates a new cursor. This is particularly useful for things like HTML, where you might want to add many instances of the same class or change the format of several hyperlinks. Learn it and love it.



5. Set a Working Project Folder

If you click on Explorer in the navigation sidebar, you’ll see a new subpanel open up. This subpanel is divided into two sections: Open Editors (i.e. files and documents currently open) and No Folder Opened. The latter is what we’re interested in.

Click Open Folder (or you can navigate to File > Open Folder in the menu bar) and select any folder on your system. This will load that folder into VS Code as the “current working project”, allowing you easy access to all files and subfolders, so you don’t have to keep flipping back and forth to File Explorer.


6. Search Across Many Files

If you’re working with files that don’t source code, the symbol-finding features above won’t be usable. So what can you do when you need to find a sentence or word but don’t know which file it’s in? You go back to the basic find function.

Ctrl + F lets you search within the current file, while Ctrl + Shift + F lets you search within all files in the entire current working project, including all sub-folders recursively.




7. Use the Command Line in VS Code

VS Code comes with an integrated terminal. On Windows, this terminal shows up as Command Prompt. On Mac and Linux, it shows up as a Bash prompt. Either way, the terminal starts off in the current working project’s directory (if one is loaded) or in your home folder (if no project is loaded).

It also supports the ability to have multiple, separate terminals. Just click the + at the top right to spawn more terminal instances, or click the Trash Can to close the current terminal. The drop-down menu makes it easy to switch between them (and doesn’t waste as much screen space as a tab-based interface might).


8. Install a New Theme in VS Code

As one would expect, VS Code lets you theme the syntax highlighting of text and source code. Unfortunately, it doesn’t allow theming of the interface itself, but the syntax highlighting is the important bit. You’d be surprised how much a good theme can boost your productivity.


9. Install Third-Party Extensions in VS Code

The last essential feature to highlight is the extensibility of VS Code through third-party extensions. As with themes, you can find them on the VS Code Marketplace (yes, these are free as well) or you can search for them in VS Code. Access the Extensions panel with the Ctrl + Shift + X keyboard shortcut.


10. Rename All Occurrences

Refactoring is a necessary aspect of writing and maintaining clean code, but it can be quite the headache—especially when you’re refactoring a large module or an otherwise huge chunk of code. So instead of hunting through dozens of files just to rename a variable or method, let VS Code do it for you.

If you select a variable/method and hit F2, you can edit the name and it will change every instance of that variable’s name throughout the entire current working project. If you only want to change within the current file, use the Ctrl + F2 keyboard shortcut and VS Code will spawn a cursor at every instance throughout the current file.

Share This

Leave a Comment

Your email address will not be published.