10 basic VS code shortcuts on Mac  
Tags: codenewbie, vscode
Published: 2021-03-22 21:04:59

[Visual Studio Code](https://code.visualstudio.com/) 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](https://visualstudio.microsoft.com/).

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. 

<img src ="https://media.giphy.com/media/85MzbHHApW0MZixvfe/giphy.gif"/>

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.
<img src="https://media.giphy.com/media/BzKqwAhkIxMDh5Ysn8/giphy.gif"/>

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. 

<img src="https://media.giphy.com/media/1hq39a7aVqPs1RHS6s/giphy.gif"/>
***
__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.

<img src="https://media.giphy.com/media/jLa0jPcLvy9g1nEwRw/giphy.gif"/>

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

<img src="https://media.giphy.com/media/gAibSfWbIFBzYCIONG/giphy.gif"/>
***
**Command ⌘ + B**
* This lets you hide the directories, If you want a wider screen

<img src="https://media.giphy.com/media/NS1lTlZFhTL79PVuck/giphy.gif"/>
***
**Option + ↑ or ↓**
* Lets you move highlighted block of code(or the current line the cursor is on) up and down

<img src="https://media.giphy.com/media/N6Z2oUWRrvXhlXoeFw/giphy.gif"/>
***
**Option + Shift ⇧ + ↓** 
* A shortcut for copy&paste of the highlighted code or the current line the cursor is on

<img src="https://media.giphy.com/media/iafRYNkGeGKOxYUsYE/giphy.gif"/>
***
**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.

<img src="https://media.giphy.com/media/iQOagRylqPWjXsXwpV/giphy.gif"/>
***
**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.

<img src="https://media.giphy.com/media/gODrVjeY2ReX0TvoOY/giphy.gif"/>
***
* 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.

<img src="https://media.giphy.com/media/Tig53QJPJjoZX1M6Wz/giphy.gif"/>
***
#### Conclusion

Hit **Command ⌘ + K S** to view all the shortcuts there or click [here](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf) 

<img src="https://media.giphy.com/media/v2OazCCZhJAHjk1rmE/giphy.gif"/>

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_**!