🔥 Save up to £500 when you confirm your place on BOOTCAMP before Easter Monday. Find out more ➡️
Visual Studio Code is a highly versatile and powerful text editor that is used by developers all around the world. One of the key aspects that makes VS Code so popular is its speed and efficiency that it brings developers, which is largely due to the vast array of keyboard shortcuts available. By utilising these shortcuts, developers can perform various tasks quickly and easily, allowing them to maximise their productivity.
In this blog post, we will take a look at some of the most useful keyboard shortcuts for Visual Studio Code that every developer should know. Note that this guide is tailored towards Mac users, but - where referenced - Linux and Windows users can simply swap the Command / Cmd key for Ctrl. Whether you are a beginner or a more seasoned developer, these shortcuts will help you to save time and effort in your day-to-day coding activities.
One of the most powerful features in Visual Studio Code is the Command Palette. This feature allows you to quickly search and run commands without having to navigate through the menus. To open the Command Palette, press Command ⌘ + Shift ⇧ + P. From here, you can search for any command, and when you find what you're looking for, simply press Enter to run it.
If you need to quickly open a file in your workspace, the best way to do this is by using the Quick File Search feature. To open this feature, press Command ⌘ + P. This will bring up a search bar, where you can start typing the name of the file you want to open. As you type, Visual Studio Code will provide suggestions based on your workspace, and you can simply select the file you want to open from the list.
When you have multiple tabs open in Visual Studio Code, it can be a bit challenging to navigate between them. However, there are a few keyboard shortcuts that can make this task much easier. To navigate between recently used tabs, hold down Ctrl + Shift + Tab, and keep pressing the Tab key until you find the right tab, at which point you can release the Tab key and subsequently the Ctrl + Shift keys. Additionally, you can jump directly to a specific tab by pressing Ctrl + 1 to Ctrl + 9, depending on the tab number - based on the order in your tab list - you want to open.
One of the great things about Visual Studio Code is that it allows you to customise your own keyboard shortcuts. If there's a specific command you use frequently, you can assign a keyboard shortcut to it to make it even easier to access. To open the Keyboard Shortcuts editor, press Command ⌘ + K + S. From here, you can search for commands and assign keyboard shortcuts to them as desired.
Visual Studio Code has an integrated terminal that allows you to run commands directly from within the text editor. To open the terminal, press Ctrl + Shift ⇧ + `. This can be particularly useful if you need to run a command that you don't want to run in your regular terminal window.
When you're working with code, it's often necessary to select text. There are a few keyboard shortcuts that can make this task much easier. For example, to select text word by word, press Command ⌘ + Shift ⇧ + Left/Right Arrow. Additionally, you can move the current line up or down by pressing Alt + Up/Down Arrow.
If you need to select multiple occurrences of the same text, Visual Studio Code has a multi-selection feature that can make this task much easier. To select the next occurrence of the selected text, press Command ⌘ + D. This will allow you to select multiple instances of the same text, which can save you a lot of time when making changes to your code.
Another essential set of keyboard shortcuts for Visual Studio Code is Undo and Redo. To undo the last action, press Command ⌘ + Z. To redo the last undone action, press Command ⌘ + Shift + Z. These shortcuts can be a lifesaver if you accidentally make a mistake in your code and need to revert it. Bonus: These commands also work in a number of other applications for the same purpose.
When you're working on a project, you might want to temporarily comment out some code to see how it affects the rest of the project. Visual Studio Code makes this process simple with the commenting out shortcut. To comment out the selected line(s) of code, press Command ⌘ + /.
Sometimes you may need to insert a new line above the current line in Visual Studio Code. To do this, simply press Ctrl + Shift + Enter. This can be useful if you need to add a new line of code above the current line without having to navigate to the beginning of the line.
In conclusion, these are just a few of the most useful keyboard shortcuts for Visual Studio Code. By utilising these shortcuts, you can save a lot of time and effort in your coding activities, making you more productive and efficient. There are many more shortcuts available in Visual Studio Code, and remember: you can find a complete list of commands and their shortcuts in the Command Palette (Command ⌘ + Shift + P). Happy coding!