VS Code: Tips and Tricks
Improve your coding workflow on Visual Studio Code
In the fast-paced world of modern work, sometimes we try to make every second count. As the demands on our time continue to increase, the quest for efficiency has become an eternal pursuit. If you are a developer and like me, seeking to automate boring and repetitive tasks, Visual Studio Code might be the tool to improve your productivity, and if you already use it, here you can learn some time-saving features and techniques that might improve your workflow. Brace yourself, as we embark on a journey to unravel the time-saving wonders of VS Code, unveiling tips, tricks, and techniques that might improve your workflow.
A high degree of customization is available, along with an extensive list of free extensions. Learning some tricks on VS Code can substantially boost a programmer’s efficiency. If you are among the developers that use VS Code regularly in your day-to-day life, I hope this content may help you with some useful tips and tricks to optimize your work and extract the best from this amazing editor.
One of the most useful and convenient resources from VS Code are the shortcuts, and there are plenty of them that many developers don’t know, besides that you can even customize them on your own. By using them, you can be more efficient and save time from tasks that would require many clicks, such as editing multiple places at once, especially when you need to manipulate data files, e.g. CSV, JSON, XML, and SQL. Also, a portion of these key bindings are the same across different platforms and softwares. Besides that, shortcuts are much more helpful for those who like smaller keyboards. Here I’ll show you some of my favorites and most used key bindings that I already taught to colleagues.
Useful shortcuts
Here I would like to share with you some of my favorite and most used shortcuts:
Ctrl + Shift + P
— Open Command PaletteCtrl + P
— Go to specific file searching by any string in its nameCtrl + K + Ctrl + S
— Open Keyboard Shortcuts 🤯Ctrl + F
— Find a text in the current fileCtrl + Shift + F
— Find a text in all files and you can filter by foldersCtrl + H
— Find and replace a text occurence in the current file
— In all find/search features you can use regex patterns by clicking on the icon ▪️*, or using the shortcutAlt + R
Ctrl + D
— Select next occurrence of the text selected
— Combined with Ctrl + Left/Right and Ctrl + Home/EndCtrl + Shift + L
— Select all occurrences in the file of the selected textShift + Alt + I
— After selecting multiple rows, the command will add one cursor at the end of each selected row- Press scroll and drag up/down — Adds multiple cursors along the lines
Alt + Click
— Add an extra cursor in the position clickedAlt + Up/Down
— Move line up and downCtrl + Shift + U
andCtrl + Shift + L
— After selecting a text or placing the cursor in a work, the command will make the text uppercase or lowercase
— For this one my suggestion is to update to useCtrl + Up/Down
arrows, as it is more intuitiveCtrl + Page Up/Down
— Change to next/previous tab
— Here I suggest to update to useCtrl + Tab
andCtrl + Shift + Tab
as it is more accessible using one hand, and it’s the same shortcut used in the browserAlt + Z
— Enable and disable word wrapCtrl + Shift + V
— Paste plain text without formatting
Useful extensions
I encourage you to take a look at the documentation of these packages, they have a pretty good overview of features and GIFs showing how they work.
- Project Manager — Organize and easily switch between projects
- Material Icon Theme — Support for a huge variety of icons for folder and file types
- Git Graph — View a Git Graph of your repository, and perform Git actions from the graph (see the cover image)
- Git History — View git log, file history, compare branches or commits
- Prettier — Code formatter for a variety of languages, especially for web development
- Dracula Official — A dark theme adopted by many developers
- WSL — Open any folder in the Windows Subsystem for Linux (WSL)
- GitHub Copilot — For AI enthusiasts — the only paid plugin from this list — Copilot provides autocomplete-style suggestions from an AI pair programmer as you code
Working with data files
During these years working with VS Code and more specifically manipulating data files such as CSV, JSON, XML, and even SQL scripts — everything that has a pattern in its structure — I already faced some issues that VS Code helped handle and later allowed me to help my colleagues with their issues. Here I’ll share some of these tricks dividing them into topics:
- Find and replace using regex is a powerful resource. Simple patterns are very helpful and save a lot of time if you need to update strings with specific patterns. Besides that, these patterns can also help later with your code when manipulating texts.
— In the example below, the aim was to remove all rows from the file that were terminated by0
. To accomplish this I searched in the file using regex by0$
, then selected all occurrences withCtrl + Shift + L
and deleted them
- Multiple selectors are good friends, as you can always update multiple places at once
—Ctrl + D
, click onScroll and Drag
,Alt + Click
,Alt + Shift + I
,Ctrl + Shift + L
— Added toCtrl + Left/Right
arrows andCtrl + Home/End
keys to navigate in the rows - Added to the previous one, check the indentation method, in most cases when you you’re using multiple cursors, adopting tabs for indentation make the work much easier instead of using spaces
- You can preview your markdown files formatted, such as readme.md, by clicking in the top right corner “Open Preview” button
- Attention to the file encoding, sometimes different and hidden characters are a pain in the neck, so checking the file encoding the first time you work with it may save you from unpredicted errors. You can check that in the bottom right corner of the window
- In Addition to the previous one, if you are working on any file that will be executed by command line, check also the EoL (End of Line) of the file, check if you need it to be CRLF or LF. You can check that in the bottom right corner of the window
— On Linux distros, EoL is marked with a single ASCII character LF -\n
— On Windows, the EoL is marked with a CR-LF pair -\r\n
— If you are on Windows and working on a project that will be executed on a Linux distribution on Cloud, you can make use of WSL and clone your repository on a Linux environment, setting the EoL to LF by default
Latest tips
You can always search for plugins that can help you with a boring task. With a huge number of users, you can usually find someone else with the same pain as yours and developed a package to help with that.
Besides that, if you have the time, a quick look into new releases sometimes reveal useful features. All this information may sound too much to adopt all at once, but as you start using them gradually, it will become natural.
If you have reached here, thanks! I appreciate your interest and hope you enjoyed it. All those tips were based on previous experiences and colleagues I was able to help, but if you want to read more, in the references I left some links to other interesting articles about tricks with VS Code.