7 Tips to improve your programming flow

7 Tips to improve your programming flow

Few shortcuts and more I wish I knew before I started to learn how to code.

ยท

4 min read

When I started learning to code I wrote all my code in very slow and inefficient way. Today, I still type code pretty slowly and there still room improvement, but I believe I have made some improvements and learned few tricks that might help you be more efficient when typing code. In this article, I would like to share these tricks with you, which I hope you will find useful and valuable.

1. Opening root folder from the terminal

You might find it funny, but it actually took me some time before I realized I can open my source folder in Visual Studio Code from the terminal.

Just navigate to your project root folder in terminal and type:

samuel@slinux:~/Projects/random-project$ code .

It might look like a insignificant tip but it actually can save you some time once you stop using your file browser to open your project folder in Visual Studio Code.

If you want to learn more about the code command just visit Visual Studio Code official docs.

2. Navigate through code word by word

It took me some time to stop navigating through code character by character. Instead of using just arrow keys to move in your lines of code. Try to use Ctrl+right arrow or Ctrl+left arrow to navigate through your code word by word. It will save you a lot of key strokes and thus a lot of time.

demo1-2021-08-29_19.32.46.gif

3. Select code word by word

Do you want to select a portion of your line of code? Just use Ctrl+Shift+right arrow or Ctrl+Shift+left arrow. Using this key combination you will be selecting your code word by word instead of character by character as I was doing it for quite a long time.

demo2-2021-08-29_19.37.52.gif

Like this you can easily and quickly select and edit or delete portions or all line of code.

4. Move lines or one line of code up and down

Tips #2 and #3 work in almost every text editor and in terminal as well. On the other hand next two tips work only in Visual Studio Code as far as I know.

Instead of selecting and using Ctrl+X and Ctrl+V to move big junks of your code up or down in your file, just select the portion of the code you want to move and while holding the Alt use the up arrow or down arrow keys to move selected code.

demo3-2021-08-29_19.47.50.gif

If you want to move only one line of code, you do not even have to select the whole line. Just leave the cursor wherever you want in the line and while holding the Alt key use the up arrow or down arrow keys to move the line up and down.

demo4moveline-2021-08-29_19.51.16.gif

5. Duplicate lines or one line of code

Very similar to the previous tip, but this time if you want to duplicate line or lines of code try to use Ctrl+Alt+Shift+up arrow or Ctrl+Alt+Shift+down arrow combinations.

demo6copyline-2021-08-29_20.25.12.gif

If you want to learn more useful shortcuts in Visual Studio Code just press Ctrl+K and immediately after that press Ctrl+S and list of all shortcuts will show up.

6. Multiple cursors

Sometimes you want to insert or type the same text in multiple places in your code. In this case, try clicking on these places with the mouse while holding the Alt key. This will create multiple cursors and you can start typing text in multiple places at once.

demo7cursors-2021-08-29_20.28.16.gif

If you like these editing tricks or hacks so to say I recommend you to visit Visual Studio Code official docs again where you can find many others hacks that will definitely improve your flow.

7. Previewing your *.md file

I used to use all sorts of online .md file editors until I discovered it is actually very easy to preview any .md file in Visual Studio Code. When editing, for example, a README.md file just press Ctrl+K+V and the preview will appear in a new side window.

readme-2021-08-29_20.49.27.gif


These are all the tips I have for you today. I hope at least one tip was useful for you. ๐Ÿ™‚

I love learning new tricks and tips too, so please let me know in the comments section what you use to improve your programming flow.

Also, if you like this article consider sharing it with your friends. Maybe they will find a useful tip in this article as well.

-- Cover photo by James Harrison on Unsplash

ย