Saturday, April 20, 2024
HomeTutorials30 VS Code Shortcuts To Make Your Coding Experience Easier

30 VS Code Shortcuts To Make Your Coding Experience Easier

Visual Studio Code or simply VS Code is a code editor. Many code editors are available in the market, but VS Code is simply the best. Eight out of ten developers will tell the name of VS Code as their favorite. Microsoft is the founder of the software. You can do anything you need to do as a developer in it. Debugging, auto code completion, syntax highlighting- you name it. VS Code makes your coding experience fruitful. However, you can code faster and more smoothly if you know Visual Studio Code shortcuts. No developer wants to deliver the product late. If you are a developer and using VS Code, you should learn about VS Code shortcuts.

Useful Visual Studio Code Shortcuts

Shortcuts are vital in programming as they make things easier and faster for developers. It’s like playing with the keyboard. To utilize shortcuts in VS Code, you will need to install some extensions and plugins at first. To accelerate your coding with VS Code, today, we will discuss the 30 VS Code shortcuts that you should know to make your coding experience easier.

01. Search Text through All Files at Once

The way to track any similar text in all of your files in the project directory in VS Code’s most prominent feature. The shortcuts are different for Windows and macOS. They are as follows:

  • Press Ctrl + Shift + F on Windows
  • Press Control + shift+ F on macOS.

When you press the required buttons, a sidebar will appear on the left of the screen. You can type any text there to search it over all your files in the project directory. This feature will assist you if you want to change a code in every file of your project. You don’t need to enter each file and adjust the text manually. This shortcut will automatically fix the problem and save a lot of time.

02 Reopen a Closed Editor

Developers usually work with massive projects. Projects like that have hundreds of files. And you have to work with several files at a time. It’s perfectly normal to close a tab by accident when working such an amount of files. However, you don’t have to fear that. With the use of a VS Code shortcut, you can easily retrieve the tab or editor.

  • Press Ctrl + shift+ T

This shortcut reopens the closed editor, so you don’t have to look for it every time you mistakenly close it.

03. Add Selection to Next Find Match

This is a handy shortcut. Suppose you are writing in VS Code, and you need to write the same code in several places. Generally, you will write each code individually or copy-paste it, which will take a lot of time. But you can use the following command to save you some time.

  • Press CTRL+D

And select the places where you want to write the same code several times. If you write the code in any one place, it will automatically be written in the rest of the sites.

04. Delete Previous Word

There may be situations when you misspell a word while writing a long sentence, but you don’t want to press backspace to remove the desired word continuously. In that case, you can use the following shortcuts:

  • Press Ctrl + backspace for Windows
  • Press Control + delete for MacOS

The VS Code shortcut eases you from the pain of pressing the backspace button continuously.

05. Delete Line

This one is actually necessary when you want to delete the previous line you just have written. There are two ways to execute it.

If you just want to delete the line, use this command:

  • Press Ctrl + X for Windows
  • Press Control + X for MacOS

In case you want to delete the line and preserve the line in the clipboard, use these commands:

  • Press Ctrl + Shift + K for Windows
  • Press Control + Shift + K for MacOS

Use the shortcuts according to the conditions you need them.

06. Select Words

Many developers are obsessed with using the keyboard only. They feel bored and irritated to use the mouse. You can select a word or sentence using the mouse. Nevertheless, you can also do it using special commands.

  • Press Ctrl + Shift + Arrow keys

The shortcut may seem simple, but it is actually quite helpful in special cases.

07. Jump to the Beginning or End of a File

This one is quite a useful VS Code shortcut. Developers make software by working for months. Eventually, a file has thousands of lines of code. When you want to go to the top of a code file or vice versa, you press the page up or page up button for quite a time. But this is actually unnecessary. You can smoothly go to the top or bottom of a VS Code file by using the following commands:

  • Ctrl + Home for going to the beginning
  • Ctrl + End for going to the end.

These are really significant to speed up your code.

08. Move a Line

Making mistakes is quite a typical case in coding. Suppose you have a written the wrong code in the wrong place. Now, you don’t want to cut and paste the code. In that case, you can just select the word or couple of words, press ALT, and press up/down arrows.

  • Press Alt + Up/Down arrow keys

09. Add Cursor Up/Down

Situations might come where you need to edit multiple lines with the same code. You don’t need to edit each line individually at that time. Just use the following commands:

  • Press Ctrl + Alt + Up/Down
  • Press Ctrl + Shift + Arrow left or right.

Use the Visual Studio Code shortcuts combined to get a better result.

10. Duplicate a Line above or below

You know, in many cases, you need to use the same line continuously several times. The else-if statement is one of those. Don’t write the same sentence every time or copy-paste them. Instead, use the following codes:

  • Press Shift + Alt + Up/Down arrow keys

Duplicate as many lines as you want in both up and downwards directions without any extra effort.

11. Fold or Unfold Code

Developers have to present the code to the clients before putting them into development. So, the code has to be understandable as well as documented well. Folding a substantial portion of a code is a good approach in that case. You can easily fold the less important part of the code by using the following shortcuts:

  • Press Ctrl + Shift+[ to fold.
  • Press Ctrl + Shift+] to unfold

These procedures will make the code short as well as presentable.

12. Navigate to a Specific Line

If you want to go to the desired line in a file with thousands of lines, don’t use the up/down arrow keys. It will kill a lot of time. Just do the following:

  • Press Ctrl + G and input the desired page number.

This VS Code shortcut is instrumental for developers handling massive projects.

13. Column box selection

Sometimes, you might need to select a lot of texts at a time. The selection of text using the typical process is quite irritating. It is hard to select a lot of words using only the cursor accurately. So, you can use the following VS Code shortcut:

  • Press Shift + Alt + Cursor

You can select text in a column box shape way with this shortcut.

14. Join Line

This an important Visual Studio Code shortcut. This line is used to convert several lines of code into a single line. Use the following command in this regard:

  • Open File > Preferences > Keyboard shortcuts and then go to action.joinLines to select your choice on Windows.
  • macOS users press Control + J

15. Code Formatting

There are many shortcuts in VS Code. But this shortcut is one of the most satisfying of all. Indentation is significant in c documentation. At the same time, you have to maintain a definite format. If you use this shortcut, you don’t have to be concerned about indentations during coding. You use the following shortcuts, and the indentations, along with other formats, will automatically be fixed.

  • Press Shift + Alt + F on Windows:
  • Press Shift + Option + F on MacOS
  • On Ubuntu Ctrl + Shift + I on Ubuntu

Notice the image given below to get the shortcut more clearly.


16. Trim Trailing White Space

Unnecessary white spaces may be present at the end or beginning of a line of code. It wastes valuable memory. You can do the following things to get rid of this problem

  • On VS Code go to Preferences > Settings > User Settings tab
  • Click the {} icon to open document.
  • Add the file “trimTrailingWhitespace”: true to the settings documents and save settings with any key binding, such as Ctrl+K.

trim trailing- virtual studio code

You can also process the shortcut by using a command pallet.

17. Split Editor

Developers sometimes require multiple editors at a time. However, VS Code has a specific shortcut for this task

  • Press Shift + Alt + \ or 2,3,4 on Windows  and Ubuntu
  • Press Command + \ or 2,3,4 on macOS

split editor

It’s convenient in side-by-side editing. So, you can split as many editors as you want.

18. Go to Symbol File

This is a simple shortcut, but it will make your coding faster. You can go to the symbol file in the following way:

  • Press Ctrl + Shift + O on Windows and Ubuntu
  • Press Command + Shift+ O on MacOS

You can also do the same process by adding @:

19. Go to Symbol in Workspace

The VS Code shortcut is similar to the previous one. In this case, you go to the symbol in the workspace. The shortcuts are as follows:

  • Press Ctrl + T on Windows and Ubuntu
  • Press Command + T on MacOS

20. Rename Symbol

Renaming a symbol is relatively easy in VS Code. You have just to select the symbol you want to rename. After that, go through the steps below:

  • Press F2 on Windows and Ubuntu
  • Press F2 on macOS

For a better understanding, look at the picture below.

Rename symbol

21. Opening and Closing the Sidebar

The sidebar is essential for any developer. You can see your required files and other materials there. However, the sidebar takes a lot of space on the screen. So, you can quickly close or open it using the following commands:

  • Press Ctrl+ B on Windows and Ubuntu
  • Press Ctrl+ B on MacOS

This VS Code shortcut helps a lot while using split editors as it saves a lot of space.

22. Command Palette

From the command palette, you can give any commands according to your requirements. Do the following to open the command palette:

  • Press Ctrl+ P on Windows and Ubuntu
  • Press Ctrl+ P on MacOS

command palette-VS code

Suppose you want to open a file. At first, Press Ctrl+ P and write the name of the file in the command palette. Then, the file will be opened in seconds. You can also get access to all the commands and shortcuts from the palette. In case you forget any shortcut, just go to the palette.

23. Open File by Matching Text

You can open files by matching texts if you key bind a shortcut. It removes the need to manually navigate through folders to reopen a file that is no longer open. Furthermore, it saves a lot of time on a regular basis. You have to do the following:

  • Enter file> Preferences > Keyboard Shortcuts
  • Search for action.quickOpen
  • Click it and bind a key according to your convenience.

Thus, you can open a file without going to the folder.

24. Open Integrated Terminal

In VS Code, the integrated terminal is quite handy. Developers often use it because of its utilities. So, there is a VS Code shortcut to open the terminal on the fly. It is as follows:

  • Press Ctrl+,` e., the backtick button

You can open it by command palette. However, this is the best way.

25. Replace All Matching Occurrences of Text in the current file

A code may appear several times in a file. In case you want to replace that code, you can use an easy VS Code shortcut. Many of you don’t know about this and manually replace the code. Moreover, it requires a considerable amount of time and effort. You can utilize the given shortcuts instead:

  • Press Ctrl+ F2 on Windows
  • Press Control+ F2 on MacOS

all selection

Therefore, select the desired word or group of words, press Ctrl+ F2 and the duplicate words will appear automatically. After that, Replace anyone, and you are good to go.

26. Switch Tabs

It’s pretty standard for developers to use multiple tabs at a time. But you don’t need to use the mouse pointer to switch among them. Just do the following:

  • Press Ctrl+1/2/3

So, press the 1/2/3 according to the tab number. Specifically, if you want to go to tab 2, just press Ctrl+2.

27. Navigate History

We rarely work on all of the files at the same time in a project. We usually work with two or three at best. In case you don’t have enough space to split many editors, you can use the file history. It not only saves the previous files we used but also offered a fast way to recover them. The VS Code shortcut to open history is given below:

  • Press Ctrl+ tab

You can also switch between the history files in a faster way.

  • Use the alt + left / right arrows

navigate hirtory

It saves time as well as gives more space to the screen.

28. Focus Debugger

The debugger is very significant for developers. You can easily control the debugger using the following shortcuts:

  • Press F5 to start
  • Pin Shift + F5 to stop
  • Press F9 for breakpoint

You can use the debugger pretty conveniently in this way. However, it will be better to change the debugging shortcuts as the function buttons are hard to reach.

29. Show Suggestions and Comment Selection

IntelliSense is an amazing feature of VS Code. It is also called code completion as it completes the half-written code and also shows suggestions. You can trigger IntelliSense in the editor by using the following shortcut:

  • Press Ctrl+ space

You can easily convert a sentence into a comment. You just have to select the group of words and do the following:

  • Press Ctrl +K + C for commenting
  • Press Ctrl + K + U for uncommenting

30. Go to Definition and Reference

The go-to Definition feature opens a new tab. At the same time, it directs to the origin of the desired symbol. To do that, place the cursor on the aimed symbol. Then press F12 to go to the source directly. Moreover, if you are on the mouse, click on the symbol by pressing Ctrl.

definiton-VS code

In addition to that, VS Code shortcut to go to the reference too. Select the symbol whose reference you want to know and simply do the following:

  • Press Shift + F12

Final Thoughts

You can produce software and develop products if you know a programming language. However, coding with efficiency is another thing. To speed up your coding, write efficient codes, and save a lot of time, you have to use an editor like VS Code and have to know the use of various tools, extensions, and especially shortcuts. Utilizing specific shortcuts will save you valuable time as well as provide you a well-documented code. That’s why we listed the best 30 VS Code shortcuts to help you code at ease.

We tried to show the most shortcuts we could in this article. There are many shortcuts other than this, which you should learn from the internet. Besides, if you think of any point that should have been included, let us know in the comment section. And always remember that hard work is the root of success. So, stop wasting time and enhance your knowledge.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.


Please enter your comment!
Please enter your name here

You May Like It!

Trending Now