Be More Productive in VS Code
· 3 min read
A reference for productive Visual Studio Code hotkeys and configurations.
TLDR
This is a quick reference for useful Visual Studio Code (VsCode) configurations that I use. It includes custom keybindings and default keybindings that I find helpful for productivity. I apologize for the lack of explanation, but I wanted to keep this as a quick reference. I hope you learn a new hotkey or configuration that you find useful.
Custom
-
CTRL + R + CTRL + Rto run code- Custom Python run command. Go to keyboard shortcut settings and search for "python" to find multiple python run commands. I bind one of these to a custom hotkey to speed up my workflow.
-
CTRL + ALT + ?to go to definition- Super useful for navigating code quickly. Instead of doing
CTRL + Clickto go to definition, I use this hotkey to quickly jump to the definition of a function or variable. This is especially useful in large codebases where you need to navigate through multiple files. You can combine this withALT + ←andALT + →to navigate through the history of definitions you have visited. These 3 hotkey combos are by far my most used hotkeys. I can understand how code is related much quicker.
- Super useful for navigating code quickly. Instead of doing
-
ALT + ?to view definition or error message on hover- Super useful for understanding code quickly. Anything you typically can see when you hover over it will be available with this hotkey. This can show variable types, function docstrings, warning messages, and more.
-
Format on Save (
CTRL + S)- Configure in settings, search for "format on save" and enable it.
Visual Studio Code Defaults
Alt + ←orAlt + →to navigate through history- Used in conjunction with
CTRL + ALT + ?to navigate through definitions and errors. These 3 hotkeys are my most used hotkeys by far.
- Used in conjunction with
CTRL + 1 / 2 / 3 / 4to navigate through different text editor groupsCTRL + Tto switch files within the current editor groupCTRL + Shift + Pto open command paletteCTRL + Dget matching occurrences of selected textHomeandEndto move to beginning and end of lineShift + HomeandShift + Endto select to beginning and end of lineShift + Alt + ↑orShift + Alt + Downto move line up or downCTRL + Fto find text within the fileCTRL + SHIFT + Fto find text across all files- This is a must for massive codebases. Good luck finding a class's method usage without this.
CTRL + ?to toggle comments- This had built-in language detection, so it will comment out the code in the language you are using. For example, in Python it will use
#, in C++ it will use//, and in HTML it will use<!-- -->. Now you don't have to remember the comment syntax for each language you use!
- This had built-in language detection, so it will comment out the code in the language you are using. For example, in Python it will use
CTRL + ←orCTRL + →to move the cursor to the next or previous word
I will continue to update this page with more useful configurations as I discover them. If you have any suggestions, feel free to reach out!
