Visual Studio Code is one of the most popular code editors used by developers, test automation engineers, DevOps specialists, and people learning how to code.
Its popularity comes from its simple interface, large extension marketplace, broad language support, and the ability to customize the environment to match your workflow.
One of the easiest ways to improve your productivity in Visual Studio Code is to start using keyboard shortcuts.
At the beginning, many people perform most operations with the mouse. They open folders in the Explorer panel, search for files manually, select commands from the menu, and highlight individual sections of code.
There is nothing wrong with that, especially when you are still learning how the editor works. Over time, however, it is worth introducing a few keyboard shortcuts into your daily workflow.
You do not need to memorize dozens of combinations at once. Start with a few operations that you perform regularly. After some time, using them will become natural, and navigating through projects will become much faster.
Below, you will find 10 practical Visual Studio Code shortcuts that are useful whether you work with JavaScript, TypeScript, Python, Java, configuration files, automated tests, or cloud projects.
The article includes shortcuts for Windows, Linux, and macOS.
1. Quickly open a file
Windows/Linux: Ctrl + P
macOS: Command + P
When working with a larger project, manually searching for a file in the Explorer panel can take more time than expected.
A project may contain dozens of directories and hundreds of files. Expanding folder after folder every time you need to open something quickly is not very efficient.
The Ctrl + P shortcut opens the Quick Open search box. You can start typing part of a file name, and Visual Studio Code will immediately display matching results.
For example, imagine that your project contains the following file:
src/components/UserProfile.tsx
Instead of opening the src directory, then components, and finally searching for the file, you can press Ctrl + P and type:
userprofile
Select the result, and the file will open immediately.
You do not need to provide the full file name or path. The search engine can match files based on partial names, which makes this one of the most useful shortcuts in everyday work.
2. Open the Command Palette
Windows/Linux: Ctrl + Shift + P
macOS: Command + Shift + P
The Command Palette gives you access to most actions available in Visual Studio Code.
After opening it, you can search for a command by typing part of its name. You do not need to remember where a particular option is located in the main menu.
You can use the Command Palette to:
- change the editor theme,
- format a document,
- open settings,
- reload the Visual Studio Code window,
- run a task,
- select a language interpreter,
- execute commands provided by extensions,
- change the language mode of the current file.
For example, to change the editor theme, open the Command Palette and type:
Color Theme
Then select the theme you want to use.
The Command Palette is especially useful when you know what you want to do but do not remember the relevant keyboard shortcut. You can think of it as a central search engine for almost every editor feature.
3. Search across the entire project
Windows/Linux: Ctrl + Shift + F
macOS: Command + Shift + F
Searching inside a single file is useful, but in daily work you often need to find every place where a specific name, value, method, or message appears.
The Ctrl + Shift + F shortcut opens the project-wide search panel.
You can use it to find:
- a function name,
- an API endpoint,
- an error message,
- a selector used in automated tests,
- an environment variable,
- a SQL query,
- a configuration value.
Imagine that you want to find every place where the createUser function is used. Enter its name, and Visual Studio Code will display all matching files and lines.
You can also limit the search to selected files or directories. It is possible to exclude locations as well, for example generated reports, build folders, or dependencies.
The search panel also supports regular expressions, which makes it useful for finding more complex patterns.
4. Open and hide the terminal
Windows/Linux: Ctrl + ``
**macOS:** Control + ``
Visual Studio Code includes a built-in terminal, so in many cases you do not need to open a separate command-line window.
Using the shortcut with the backtick key allows you to quickly show or hide the terminal panel. The backtick key is usually located in the upper-left part of the keyboard, close to the 1 key.
You can use the terminal to run commands such as:
npm install
npm run dev
npm test
git status
git pull
npx playwright test
docker compose upThis is particularly convenient when developing web applications, creating automated tests, or working with DevOps tools.
Instead of constantly switching between the editor and a separate terminal window, you can perform most operations in one environment.
Visual Studio Code also allows you to create multiple terminal sessions and use different shells, including PowerShell, Command Prompt, Git Bash, Bash, and Zsh.
5. Show and hide the side bar
Windows/Linux: Ctrl + B
macOS: Command + B
The Visual Studio Code side bar contains the file explorer, project search, source control panel, extensions, and other important tools.
The panel is useful, but on a smaller screen it can take up a significant amount of workspace.
The Ctrl + B shortcut lets you hide the side bar and display it again whenever you need it.
This can be helpful when:
- working on a laptop,
- viewing long lines of code,
- comparing two files side by side,
- recording a course or tutorial,
- focusing only on the currently opened file.
It is a simple shortcut, but it can noticeably improve your working comfort. Instead of resizing the panel manually, you can recover additional screen space with one key combination.
6. Move a line of code
Windows/Linux: Alt + Up Arrow or Alt + Down Arrow
macOS: Option + Up Arrow or Option + Down Arrow
While editing code, you will often notice that a line should be moved a few positions higher or lower.
The standard approach would be to select the line, cut it, move the cursor to the correct position, and paste it.
Visual Studio Code offers a much faster option.
Place the cursor on the selected line and press Alt together with the up or down arrow. The entire line will move.
The shortcut also works with multiple selected lines.
For example, if an import statement is placed in the wrong location, you can move it without using the clipboard. You can also reorder array elements, object properties, test steps, or configuration rules.
Visual Studio Code preserves indentation while moving the content, which makes the operation fast and convenient.
7. Add multiple cursors
Windows/Linux: Alt + mouse click
macOS: Option + mouse click
Multiple cursors, also known as multicursor editing, are one of the most useful features of modern code editors.
Hold Alt and click in several places in the document. Visual Studio Code will create an additional cursor in every selected location.
Anything you type or delete will then be applied in all those places at the same time.
For example, imagine the following code:
const userName = "Adam";
const userEmail = "adam@example.com";
const userRole = "admin";If you want to add the same text to several lines, you do not need to edit each one separately. You can create multiple cursors and make the change once.
This feature is useful for:
- editing similar properties,
- adding prefixes,
- modifying structured data,
- updating multiple selectors,
- editing repeated code,
- preparing test data.
You should use it carefully, however. If the selected lines have different structures, it is easy to modify the wrong part of the code accidentally.
8. Go to definition
Windows/Linux/macOS: F12
When reading code, you will often see a function, class, method, or variable and want to check where it was defined.
Place the cursor on the selected symbol and press F12. Visual Studio Code will try to open its definition.
For example, you may see the following method call in an automated test:
await loginPage.login(username, password);To see how the login method works, place the cursor on its name and press F12.
Visual Studio Code may immediately open the file containing the method implementation.
This feature works especially well in TypeScript projects because the editor has access to type information and code structure.
Going to a definition is useful when:
- learning a new project,
- analyzing existing code,
- finding an interface implementation,
- inspecting library code,
- debugging an issue,
- reviewing a pull request.
You can return to your previous location using:
Windows/Linux: Alt + Left Arrow
macOS: Control + -
This allows you to move between a function call and its implementation without manually searching through files.
9. Rename a symbol
Windows/Linux/macOS: F2
Renaming a variable or function with a basic search-and-replace operation can be risky.
A project may contain several unrelated variables with the same name. Replacing the text globally could therefore modify places that should remain unchanged.
The F2 shortcut opens the Rename Symbol feature.
Place the cursor on a variable, function, class, method, or another symbol and press F2. Enter the new name, and Visual Studio Code will try to update all related references.
For example:
const result = calculatePrice(products);The name result is quite general, so you may decide to rename it:
const totalPrice = calculatePrice(products);In a properly configured project, Visual Studio Code will also update other references to this variable.
This is a simple example of code refactoring. It is usually safer than editing every occurrence manually.
After a larger refactoring operation, it is still a good idea to run your tests, type checking, and linting tools.
10. Format the entire document
Windows/Linux: Shift + Alt + F
macOS: Shift + Option + F
Readable formatting is important both for the author of the code and for everyone else working on the project.
The Shift + Alt + F shortcut formats the currently opened document.
Depending on the language and project configuration, Visual Studio Code may use a built-in formatter or an extension such as Prettier.
Formatting may improve:
- indentation,
- spacing,
- bracket placement,
- long line wrapping,
- object structure,
- JSON readability,
- HTML and CSS formatting.
For example, you may start with the following object:
const user={name:"Adam",email:"adam@example.com",active:true};After formatting, it may look like this:
const user = {
name: "Adam",
email: "adam@example.com",
active: true,
};In team projects, it is worth defining common formatting rules and storing the configuration in the repository.
This helps keep the code consistent regardless of who edits it.
You can also enable automatic formatting whenever a file is saved. The relevant setting is called Format On Save.
This can reduce unnecessary differences in source control and help maintain a consistent coding style.
How to view all Visual Studio Code shortcuts
Visual Studio Code includes a dedicated view containing all configured keyboard shortcuts.
You can open it using:
Windows/Linux: Ctrl + K, then Ctrl + S
macOS: Command + K, then Command + S
These combinations should be pressed one after another. First use the initial shortcut, then the second one.
In the Keyboard Shortcuts view, you can:
- search for available commands,
- view assigned key combinations,
- change existing shortcuts,
- remove keybindings,
- add your own shortcuts,
- identify conflicts between commands.
Keep in mind that some shortcuts may behave differently depending on your operating system, keyboard layout, editor settings, and installed extensions.
If a shortcut does not work, open the Keyboard Shortcuts view, search for the command name, and check which combination is currently assigned.
Is it worth learning keyboard shortcuts?
Keyboard shortcuts will not automatically make your code better or eliminate bugs. They can, however, make repetitive tasks much faster.
The main benefit is not saving one or two seconds on a single action. The real advantage is reducing the need to constantly move your hands away from the keyboard and search through the interface.
Shortcuts can help you:
- move between files faster,
- find code more efficiently,
- run commands,
- inspect implementations,
- rename symbols safely,
- format code,
- work with the terminal.
Do not try to memorize every shortcut in one day.
A better approach is to choose two or three shortcuts and use them consciously for several days. Once they become part of your natural workflow, add a few more.
A good starting set is:
Ctrl + Pfor opening files,Ctrl + Shift + Pfor running commands,Ctrl + Shift + Ffor searching across the project,- `Ctrl + `` for opening the terminal.
These four combinations alone can noticeably improve the way you work with Visual Studio Code.
Summary
Visual Studio Code offers hundreds of commands and keyboard shortcuts, but you do not need to know all of them.
The most important thing is to learn the combinations related to operations you perform every day.
Opening files, searching through a project, using the terminal, renaming symbols, and formatting code are tasks that appear in almost every software project.
Introduce new shortcuts gradually.
At first, you may still need to check the correct combinations. After some time, however, you will start using them automatically.
That is when Visual Studio Code becomes more than just a code editor. It becomes a faster and more comfortable working environment.
