When you are programming you often do small repetitive tasks. You might be inserting delimiting characters in the right place or renaming variables. Here are five features in Visual Studio Code I find useful. They help with trivial chores and lets you focus on more important things.
1. Add missing properties
You have an interface and you need to populate an object with the fields. Use this code action to help with this tedious task. It works with types too.
2. Convert concatenated strings to template string
Template strings are easier to read. It's easy to forget a whitespace somewhere when concatenating strings. Get rid of them with this action.
mac: command .
win: ctrl .
See there was a missing whitespace in there! 👀
3. Add braces to function
Sometimes you need to change something or add a line to a short arrow function. I always make some small mistake when doing this by hand. It's either one {
too many or few but with this feature you don't have to worry about it.
mac: command .
win: ctrl .
4. Convert to named function
Can't decide between function and const? Neither can anyone else but switching between them is super simple.
mac: command .
win: ctrl .
5. Rename
Last but not least, renaming things is a simple task that you often do. A good habit is to use the built in rename feature. It will update the name in all places at once, including other files.
mac: F2
win: F2
What's missing from this list?
Did you find this helpful? Do you think I missed something that every TypeScript VS Code user should know about?
Please feel free to comment with your suggestions! Thanks for reading.
Top comments (2)
Adding missing props is very neat and I didn't know about it!
Wow using VSCode for quite a while but this will speed up my developing speed. Thanks a lot.