As I was working today, I noticed that I don’t know much keyboard shortcuts in Visual Studio for Mac. So I’ve decided to collect all of them, add some unknown and share them with you. At the end of this article, you can find a link to the pdf in which all of them are written.
One more thing to add before we begin. In Visual Studio for Mac preferences, under Key Bindings section, you can choose the Scheme of key bindings. You can select the scheme from this list.
This post will be about the first one: “Visual Studio”
Sometimes you just need to find the references of the specified object. In this case, simply press
Cmd + Shift + R or Shift + F12
and this will happen:
Go to declaration
Whenever you want to go to the object/type declaration press
Cmd + mouse click or F12 or Cmd+D
When having a cursor in a line just press
Cmd + or F9
so the breakpoint will appear.
In case you want to disable/enable this breakpoint simply press
Cmd + Alt + / or Cmd + F9
When the breakpoint is hit and you want to step into the definition simply press.
Shift + Cmd + I
Maybe you want to go to the next line of code? No problem:
Shift + Cmd + O / F10
Do you want to step out of function? No problem:
Shift + Cmd + U
Or maybe you just want to continue the program without further debugging?
Cmd + enter
So let’s imagine your code get’s wrongly formatted. As long as C# code is not that big problem, wrongly formatted XAML files can be pretty painful.
So whenever you want to format your code just press
Ctrl + I
You want to indent/unindent the section? Easy
Cmd + ]
Cmd + [
Whenever you want to rename the field/variable/property/whatever and do it once so it will auto-update elsewhere. Simply press:
Cmd + R
Toggle line comment
When you want to either format one line of code, or a whole block of code then simply select the code and press
Cmd + /
This one is simply complicated but works fine. You can still edit this shortcut!
Cmd + Shift + Alt + left arrow
When quickly navigating between opened files simply press
Ctrl + tab
and navigate through the list with Tab button. If you want to cancel the selection press ESC
Close all files
How many times did you have a situation when too many files were opened? In this case, when you want to close them all simply press.
Cmd + Shift + W
On the other hand when you want to close only one file:
Cmd + W
Add files to project
That’s kind nice one, as opening the context menu, and choosing “Add files” is quite time-consuming. In case you want to add files to project, select the folder to which you want to add the file and
Alt + Cmd + A
Just a shortcut for building a project.
Cmd + K / Shift + F6
Similar to the one above but builds the whole solution
Cmd + B / F6
Clean the project
Cmd + Shift + K
Just for a quick start the project🙂
Cmd + Enter / F5
When having an error or warning simply click on it and press
Alt + Enter
Just a standard find option in the document
Cmd + F
When having search bar opened
Cmd + G / F3
Show the intellisense
When you want to show the intellisense
Ctrl + Space
Go to line
That’s interesting on. Who knows to which line he want’s to go?! :O
Cmd + L
Replace in files
Another way of changing the names in files but in my opinion more dangerous then Ctrl + R
Cmd + Alt + F
That’s quite good tool, but is has limitations. Nice to use it with modifiers.
hold Alt+ select with mouse
Move line of code
Sometimes you just want to move the line of code 2 lines up/down. You can probably cut the whole line, go to the chosen place and paste. You can do it quicker.
hold Alt + navigate up/down with up/down arrow
Go to the beginning/end of the line
These are nice mac shortcuts for navigating through texts. Works on Mac, not only in VS for Mac.
Cmd + left arrow/right arrow
Go to the beginning/end of a document
Similar to the one above but navigates vertically.
Cmd + arrow down
Two editor column
That’s something for people who have big displays and like to have as much code as possible on their’s display.
One editor column
And that’s for getting back to the standard view 🙂
Zoom in/zoom out
In case you have a prelection/you want to show your code on the display you might want to adjust the font size by pressing
Cmd + “+” or ”-”
That’s almost all 🙂. I’ve created the .pdf file with all shortcuts in one place. You can download it from here. If I missed something or if you know other useful shortcuts please let me know in comments!
If you liked this post, don’t forget to 👏!
Gurupriyan is a Software Engineer and a technology enthusiast, he’s been working on the field for the last 6 years. Currently focusing on mobile app development and IoT.