DEV Community

Aaron Minyard
Aaron Minyard

Posted on

Visual Studio Code Shortcuts for Mac

Hello and welcome back coders! This post continues the theme from my first post which covered command line shortcuts, but this time around I will cover helpful shortcuts and tips while using VS Code.

Autosave is your friend. If you're an all manual type of person, and would like to wear out the print on your command and s keys, go for it; but using autosave will save you time and undoubtedly keep you from trying to view changes that you "thought" you saved.

VS Code has some command line shortcuts that will come in handy. The first of these is 'code .'. Provided that you are in the appropriate/desired directory, typing in 'code .' will open up the entire current directory you are in.

The other command line shortcut that is very useful is 'code -r'. This shortcut opens your current directory in your most recently used VS Code window.

VS Code shares many common shortcuts with iOS. Among them: '⌘x' for cut, '⌘c' for copy, '⌘f' for find, '⌘w' to close your current window, '⌘n' to open a new file, '⌃⌘f' to toggle full screen, '⌘s' to save, and '⇧⌘s' to save as.

There are also a ton of shortcuts that are more specific to VS Code. One of my personal favorites, is '⇧⌥ + click'. If you need to edit multiple lines at the same time, this command will add your cursor in each place you click while holding down ⇧⌥. For example, say you made the same syntax error on 8 different lines, this shortcut will allow you to retype the correct thing only once.

Another favorite of mine is '⌘d'. While you have a word or item highlighted, using this command will go down the page and pick out every instance of the word or item you have written. Say you typed 'from' but meant to type 'form' 12 times. Rather than going through and highlighting/retyping the word 12 times, you can just hit 'd' while holding down '⌘' 12 times, and retype the word once.

For an even higher level of efficiency, use '⇧⌘l'. After highlighting one instance of a word on your page, this will highlight every occurrence of the word on the page.

To comment out only the current line you're typing on (or uncomment if it's currently commented) press '⌘/'.

If you'd like to go to the top of the page you're working on, press '⌘↑'. To go to the end of the page, press ⌘↓.

To highlight the entire line you are currently on, press '⌘l'.

To highlight a chunk of text on any number of lines beginning where your cursor is, use '⇧⌥ + drag mouse'. This is very helpful if you need to change larger blocks of code.

To indent the line you are on, regardless of where you are on that line, press '⌘]'. To outdent, press '⌘['.

If somehow you closed out of your tab, press '⇧⌘t' to reopen your closed tab.

To hide (or show if hidden) your sidebar, press '⌘b'.

Hopefully you all were able to glean a bit of useful knowledge from this post. While writing this I learned some new shortcuts that will undoubtedly prove themselves useful.
Becoming comfortable with shortcuts can certainly help you become a more efficient coder. Thanks for reading!

Top comments (0)