Back to Freecodecamp

What Are Several Useful Keyboard Shortcuts for Maximizing Productivity in VS Code?

curriculum/challenges/english/blocks/lecture-working-with-code-editors-and-ides/672d456f4ac35950b300e93f.md

latest3.7 KB
Original Source

--description--

You're likely already familiar with some of the basic shortcuts, which are inherited from your operating system. Shortcuts like Ctrl + S to save, Ctrl + C to copy, and Ctrl + V to paste all work in VS Code.

But there's a few that are application specific and can still level up your productivity. It's worth noting that some of these shortcuts may differ by operating system.

For example, Shift + Alt + F will run your configured formatter (such as prettier, for a JavaScript project) on the currently opened file.

Or Ctrl + Shift + F (Windows), or Cmd + Shift + F (Mac), to search the text contents of all the files in your workspace. Then Ctrl + Shift + H (Windows), or Cmd + Shift + H (Mac), if you want to run a find-and-replace.

If you need to remove a line, Ctrl + Shift + K (Windows), or Cmd + Shift + K (Mac), will delete it.

Need some extra room for all your code? Ctrl + B (Windows), or Cmd + B (Mac), will hide the sidebar - which has the file list and extensions menu.

Or maybe you just can't see your code? Ctrl + plus (Windows), or Cmd + plus (Mac), will increase the scaling of the editor, and Ctrl + minus (Windows), or Cmd + minus (Mac), will decrease it.

Another helpful feature in VS Code is multi-line editing, which allows you to make changes across several lines at once. For example, you can place multiple cursors by using Ctrl + Alt + down and Ctrl + Alt + up (Windows/Linux), or Option + Command + down and Option + Command + up (Mac), to extend the cursor to consecutive lines. You can also press and hold Alt (Windows/Linux) or Option (Mac) and click to add cursors on separate lines wherever you need them. Once the cursors are placed, anything you type or delete will apply to all those locations simultaneously — which can save a lot of time when working with repetitive code.

Finally, if you forget any of these shortcuts, you always have Ctrl + Shift + P (Windows), or Cmd + Shift + P (Mac), which opens the command palette for you to select whatever you may need.

With this knowledge, and maybe a little practice, you are well on your way to becoming a VS Code power user.

--questions--

--text--

Which Windows keyboard shortcut is used to run the configured formatter on the currently opened file in VS Code?

--answers--

Ctrl + F

--feedback--

The lesson mentions a specific shortcut for formatting the current file.


Shift + Alt + F


Ctrl + Shift + F

--feedback--

The lesson mentions a specific shortcut for formatting the current file.


Alt + F4

--feedback--

The lesson mentions a specific shortcut for formatting the current file.

--video-solution--

2

--text--

What function does the keyboard shortcut Ctrl + Shift + K (Windows/Linux) or Cmd + Shift + K (macOS) perform in VS Code?

--answers--

Opens the command palette.

--feedback--

The lesson describes a shortcut for removing a line of code.


Increases the editor's text size.

--feedback--

The lesson describes a shortcut for removing a line of code.


Deletes the current line.


Hides the sidebar.

--feedback--

The lesson describes a shortcut for removing a line of code.

--video-solution--

3

--text--

Which Windows keyboard shortcut opens the command palette in VS Code?

--answers--

Ctrl + P

--feedback--

The lesson mentions this shortcut last as a way to access any command you might forget.


Ctrl + Shift + P


Alt + F4

--feedback--

The lesson mentions this shortcut last as a way to access any command you might forget.


Ctrl + Space

--feedback--

The lesson mentions this shortcut last as a way to access any command you might forget.

--video-solution--

2