8 Valuable Shortcuts for Visual Studio (Mac Users)

I believe everyone likes a good shortcut, and I personally like to complete tasks or goals in the most efficient fashion. Personally, I’ll choose the quickest route every time as long as it’s safe and legal or under the correct guidelines/standards. Time is precious and perpetually so why waste a second? This article is dedicated to early developers and users to Visual Studio Code. I would like to provide a few shortcuts(for mac users) that I use daily in VS Code that I have adopted over the past couple months. I wish someone would have showed me these shortcuts when I first started using VS Code!

Save

cmd + s

I think I use this command more than any other. This will save any file in VS Code that is currently selected in the file tab. There is a white ball next to the file name tab if there are any unsaved changes to the current file. Use this shortcut and they will disappear! Your file will also be saved!

Before

The white ball in the top right corner indicates this file has unsaved changes

After

This file is saved!

Comment Out

cmd + /

Probably the most used shortcut in VS Code besides copy, paste, and save. After highlighting the selected text, use this shortcut to easily comment out any code.

Before

Select the line of code you would like to comment out

After

The same line in the above image is commented out now

Find Text/Item

cmd + f

Use this shortcut to easily find an item matching the search bar filter. This comes in handy when code files get lengthy. I use this shortcut in my CSS files to locate ids, classnames, and elements. This is really helpful compared to manually sifting through the CSS file(especially if it is a big project).

Before

Press the shortcut to open the search filter

After

Once the filter displays, type in any text to highlight or search for it

Move Code Line Up/Down

opt + arrUp or opt + arrDown

Sometimes when writing code, you may have to change the scope of an item or move a code line vertically. This can be achieved by selecting/highlighting a line of code and performing the above shortcut. Keep in mind this will alter the entire line. One word or piece of code can’t be moved individually without copying and pasting it or deleting and rewriting it. I use this shortcut to change the scope of items all the time!

Before

Line 5 will be highlighted and moved to the op

After

After the command line 5 is now line 4 and vice versa

Open a VS Code Project From External Terminal

code .

I like to create new projects from the mac terminal, and then open them with the above command. Make sure you are in the correct directory when using this shortcut to open a project!

Before

This will open the project in VS Code, “open .” will open the actual project directory.

After

The project is open in VS Code now

Indent Code Line

tab

This one is pretty obvious, but just in case! Use this command to write correctly indented code. This is very important for ensuring clean and organized code.

Before

There are no current indentions

After

All 3 lines are indented once after the shortcut is used once.

Shut Down VS Code Terminal Server

ctrl + c

The commands to start up a server in VS Code may be different, but shutting one down is the same. Use the above shortcut to shut down any currently running server. This shortcut must be performed while in the VS Code terminal.

Before

This is a React server currently running

After

This server is shut down now and the blank line is a good sign

Open VS Code Terminal

ctrl + `

This shortcut will open the terminal inside of VS Code. Make sure you have the program selected or open when performing this shortcut.

Before

No terminal is currently opened

After

After the shortcut is used, the terminal is now displayed at the bottom of the application

Undo

cmd + z

The awesome undo command. As programmers we constantly make mistakes and need to ‘undo’ something. Thats where this command comes in handy. This will quickly undo the previous change or alteration.

Before

After Change

Undo will only undo the previous change. For example, if you type out a long string, only the last word typed will be undone

After Command

After the command the last word added was removed

I hope you find these shortcuts helpful. There are more shortcuts available for VS Code, but I solely wanted to provide my most commonly used shortcuts. If you have a shortcut I didn’t mention and you would like me to add it, please feel free to contact me. You can contact or connect with me on LinkedIn, and you can also check out my portfolio site if ya like! Have a great day!

Full Stack Software Engineer