DEV Community

Cover image for 10 basic VS code shortcuts on Mac
Alexa Gamil
Alexa Gamil

Posted on

10 basic VS code shortcuts on Mac

Visual Studio Code is a lightweight free, open-source, code editor that is available to Windows, Linux, and macOS. It supports many programming languages including Ruby, JavaScript, Python, C++, and more. Also, take note that this is different than Visual Studio.

As I use VS Code for my code editor, I learned more shortcuts to write code efficiently. If you’re just starting to learn how to code, these tips will be extremely helpful in your coding journey! I know it has been for me =]

Command ⌘ + D

  • This lets you select the word at the cursor or the next occurrence of the selected word.

This was useful whenever I come up with a better variable name. It saves me time having to manually update the rest of the code.

Two things to keep in mind, it is NOT case sensitive and it is NOT only looking for the EXACT word, the search term could a be part of another word.


Command ⌘ + F

  • Opens a widget and allows you to find text on the entire file it was run, the results will be highlighted. You can press enter to highlight the next occurrence.

You can also choose to use this to replace the highlighted words by clicking on the arrow on the left side of the input.

Again it is NOT case sensitive. This was especially helpful when I’m looking for a specific function in a sea of code.


Shift ⇧ + Command ⌘ + F

  • Same functionality with Command F but this allows you to search over ALL the files in the current directory you are in.


Command ⌘ + \ (backslash)

  • This command lets you do two things. If you click anywhere on your code editor, this will split your editor to your right. If you click on your terminal, it splits your terminal.

I used this a lot when I needed to look into my rails console without having to kill the server.


Command ⌘ + P

  • Lets you quickly open files by typing in the filename


Command ⌘ + B

  • This lets you hide the directories, If you want a wider screen


Option + ↑ or ↓

  • Lets you move highlighted block of code(or the current line the cursor is on) up and down


Option + Shift ⇧ + ↓

  • A shortcut for copy&paste of the highlighted code or the current line the cursor is on


Command ⌘ + ]

  • This allows you to indent the code where the cursor is OR the highlighted chunk of code and Command ⌘ + [ to do the reverse. Also, take note that you also don’t have to highlight the whole line of code.


Command ⌘ + ← or →

  • To get to the start or the end of the current line of code your cursor is on. Command ⌘ + ↑ or ↓ To get to the start or the end of the file you are on.


  • I know this one is here, but it took me a couple of months to notice that it was even there. This closes your editors and this collapses your folders without manually closing them one by one.


Conclusion

Hit Command ⌘ + K S to view all the shortcuts there or click here

Honestly, as a beginner, looking at that pdf was overwhelming so I thought it would be a good idea to write specific ones that have been useful to me. These 10 shortcuts alone made it more efficient for me to code. Practice these shortcuts and it will become second nature in no time. Happy Coding!

Top comments (1)

Collapse
 
ineeader profile image
Inee Ader 🐌

Nice! I knew some of these, but the rest is new to me! I remember accidentally CMD + B-ing all the time and freaking out thinking I ruined something for a second! 😂 Thanks for posting!