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
After
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
After
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
After
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
After
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
After
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
After
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
After
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
After
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
After Command
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!