The navigation features look straightforward, but, at first glance, they don't seem very useful. So, for this part of the tutorial I suggest you one thing:
Take the mouse from the side it's currently on and move it to the other side of the keyboard
This will force you to start using the shortcuts I am about to tell you, believe me, after using them for a few hours you will regret not knowing about them before. This is how much more efficient it makes you!
1) Back / Forward (ALT
+ ←
/ →
)
By far, the best way to jump from a part of a file to another is through this shortcut. Some may argue that CTRL
+ TAB
does the same thing although this is a more complete feature since it retains history in places on the same file and the history is retained even after using this shortcut (you can go back and forth without changing the actual history)
2) Open previous file (CTRL
+ TAB
)
I am sure many know about this feature so I won't get into detail here. All you need to know is, similarly to the Back / Forward feature, this let's you navigate to/from previously viewed files.
One important note here, you can also navigate forward with (CTRL
+ SHIFT
+ TAB
).
3) Navigate to next error (F8
)
When refactoring, this feature is one of the best. You can hit F8
and fix every single error until you run out and have finished refactoring. It's simply a breeze to fix errors using this.
Similar to the previous one you can navigate backwards (to the previous error) using SHIFT
+ F8
.
One issue with this feature is that there is no way to navigate on only the errors or only the warnings. Do you guys know of any way to customize this?
End
And that is it for code navigation, I will later on, create a post about navigating through the editor for completeness sake.
- Have you ever tried unplugging your mouse and work only from your keyboard?
- Which of the shortcuts have you learned about in this post?
Top comments (5)
I move back and forth between Windows (at work) and Mac (at home) a lot. The thing that always melts my mind is VS Code shortcuts that are almost the same (e.g.
ctrl + b
vscmd + b
), and short-cuts that are completely different (e.g.ctrl + k, s
vsopt + cmd + s
). T_TAlso,
ctrl + shift + p
to open the command palette is a good one.I wonder why they chose to do this... On Windows, some of them are very similar to Visual Studio's shortcuts.
Opening the command palette is one of the shortcuts I always forget due to using
CTRL
+P
and just prefixing my search with>
.That is the sole reason I didn't recently replace my old work laptop with a Mac. I couldn't get over how nonsensical the apparently random switches between
cmd
andctrl
were.Great post, shortcuts are THE BOMB.
I consider myself a avid shortcut user and here are some more:
ctrl + r
: open recent projectctrl + q
: open views panel (release ctrl to select)ctrl + b
: toggle side panelctrl + shift + g
: open source controlctrl + shift + x
: open extensions panelctrl + shift + e
: open project explorerctrl + shift + f
: open search panelctrl + \
`: toggle terminalctrl + shift + \
`: open new terminalctrl + p
: go to filectrl + n
: start new filectrl + shift + n
: start new VS Code instancectrl + shift + c
: open external terminal on current project rootctrl + w
: close current filectrl + pageup/pagedown
: navigate to next/previus opened fileThere are a lot more shortcuts, but these are the ones I use the most.
These are great. Another one I use if using split view:
ctrl + [1, 2, 3...]
: Focus the [first, second, third...] open panel. Splits to create another panel if one doesn't exist.