Text editor tips and tricks to boost your productivity
Alejandro Bezdjian
Posted on September 13, 2019
Recently, I was peer programming at work and, whithout thinking, I started to use a few editor tricks I had learned a while ago. My co-worker was amazed with them and picked up a few. At first I thought it was no big deal, but a few days later I began to observe that there are a lot of people who don't know many of these tricks. Since the tools we use have a lot of functionalities to make us more productive, it's a shame that we spoil them. That's why I thought it would be a good opportunity to transfer this useful knowledge and help others improve their productivity.
Building blocks
All the tricks I'll show you are a combination of small pieces that seem insignificant at first sight, but are very powerful when they are combined. At the end I will show you some examples that (hopefully) show how useful these tricks are.
The examples were created using VS Code on a mac, but all these functionalities should be available in every editor and IDE.
Moving cursor
Let's start slowly but surely.
Use the arrows of your keyboard to move the cursor one step at a time:
Using option + cursor move the cursor between words:
User cmd + cursor to move the cursor to the end or beginning of line:
Using the option key, you can move any line:
I use cmd + x to delete a line, this actually cuts it, but I don't really care (if you do care, use cmd + shift + k):
Highlighting
This also seems silly, but it's important that we know them all.
Using shift + cursor we can highlight words character by character:
To improve this, we can use shift + option + cursor to highlight whole words:
We can boost this using shift * cmd + cursor to select the entire line:
Multiple cursor magic
Now we are getting to the most important thing in my opinion, controlling multiple cursors.
First let's create them, we can use cmd + click using the mouse or cmd + option + up/down cursor with the keyboard only:
Normally, the selections of each cursor are copied separately and you can copy and paste them anywhere. If you have the same number of cursors as when you copied this is what happens:
If you have a smaller or larger number of cursors than when you copied, all the copied selections will be pasted on every cursor you have at the moment.
I use the next one a lot. When you select something, you can use cmd + d to select the next matching selection. This is extremely useful as we will see in one of the examples at the end. Each selection will create a cursor for it:
Auto closing characters
These is similar to the HTML auto closing tags function (that I also recommend) but with characters that have a closing pair, for example:
Examples
All the previous blocks will be useful in %90 of the times (more or less). The examples I'll show you are simplified real case scenarios and I hope the animations are self-explanatory (if there is something unusual I will try to explain what I did).
Here I added a space at the beginning so I would get a cursor where I wanted (this is another trick that you learn from practice).
Of course there are other ways to solve them, your creativity is your limit!
Extras
There are other features that editors have that you definitely should know:
- Find and open a file by name: in my case is cmd + d but other editors and IDEs have them mapped differently.
- Use autocompletion: if you develop in Java or similiar you are probably used to this, but editors have a lot of plugins for other languages that can help you.
- Find words in a file using regexp. This one is a bit more difficult (because you have to know regular expressions) but is very useful from time to time:
Once you found the text you want with your regexp, use shift + cmd + L to select it.
I hope you found these tricks useful and help you be more productive!
Posted on September 13, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.