6 Tips to Improve Your Coding Speed [LAZY EDITION]

“I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.” - Bill Gates

I couldn't agree more with this old quote from Bill Gates. I found that as I'm thriving as a developer, I tend to get lazier and the lazier I get, the more I acquire fast coding techniques. Let me share some of my favorite techniques with you folks.

1. Move cursor by word

Let's start with the most basic one. I believe most of us are already using this. It's simple, you can use the keyboard shortcuts Ctrl +←/→ (Windows) or Alt +←/→ (Mac)
Move cursor by word

Now you can navigate the codebase faster.
If you hold the Shift button along the way then it selects the word for you. Neat!

2. Add cursors to line ends

Let's say you have to edit multiple lines of content to be the same, you can simply highlight all the lines and split the cursors to each line's end. Then you can edit those lines simultaneously.
Add cursors to line ends

The actual command name depends on the editor you use. Mine is Visual Studio Code and the exact command for this is "Add cursors to line ends". The shortcut key is Alt + Shift + I (Windows) or Command + Shift + l (Mac).

3. Add selection to next find match

When you want to replace some "A" with "B" but the "Replace All" function just replaces every occurrence and ruins the mood, try this.
Add selection to next find match

For Visual Studio Code, the shortcut is Ctrl + D (Windows) or Command + D (Mac).

4. Join lines

Sometimes after refactoring, you find out that a part of your code containing multiple lines can be reduced to a single line for better readability. Select all the lines and join them. For VS Code, that's the Join Lines command Ctrl + J (Windows) or Command + J (Mac).
Join lines

You might also notice that I've used tip number 3 to format the space between each function chain. However, if you have some code formatting or linting tool set up with an auto-fix feature, that will solve the problem right away.

Another example would be copying a multiline paragraph and storing it as a string variable.
Join a paragraph to a single line string

5. Move Line(s) Up/Down

Want to rearrange function order while refactoring or want to change the order of code execution? Have you been using the Cut/Paste method? Worry not, we have an easier way to do this.
Move multiple lines

Move a single line

Notice that the editor also takes into account the indentation style if the language syntax is recognized. For VS Code, the key command is Alt + Up/Down Arrow.

6. Duplicate selection

You can actually duplicate your current selection which is very useful for populating a list or any kind of collection depending on the context.
Duplicate selection


Extra: Use extensions

As mainstream editors are open to extension contributions, we can find many useful plugins that speed up our workflow. What extension to use depends on your use case. I can give you an example. Very often I have to create mock data with running numbers, so I ended up using Insert Numbers.

Insert numbers

As you can see, being lazy led me to find better and faster ways of finishing redundant steps. This might not feel like it has a big impact,  but when used frequently, it can be a huge time saver resulting in higher productivity.

Which one do you use most often?

I'd like to know which of these matches your preference. Also, I'd like to learn some cool techniques from you as well. Feel free to leave comments in the comment section to share your ideas and methods. If you find this useful please make sure to leave a like and share this blog post. Thank you!
Like 4 likes
Aun Trirongkit
Aun Jessada - A full-stack Javascript developer interested in frontend, animations and user interface interaction. Experienced in game development, React and NodeJS. Also, a part-time musician, singer and songwriter.
Share:

Join the conversation

This will be shown public
All comments are moderated

Get our stories delivered

From us to your inbox weekly.