DEV Community

Shubhra Agarwal
Shubhra Agarwal

Posted on • Edited on

Keyboard shortcuts which will make sure you don't have to touch your mouse while writing code

There are times when you might feel like reaching for the mouse to execute a certain task. But we all know that shifting our hand to and fro from the mouse reduces our productivity. So,

Here are 10 keyboard shortcuts that will help you to speed up your coding process 🧵

These shortcuts work with a majority of code editors and IDEs like VS Code, Atom, Sublime etc. If these doesn't work for you, make sure to check the settings of you editor.

Let's Begin 👇

1️⃣ Copy/Cut/Paste Entire Line

You might be aware about Ctrl+C/X/V but there's a trick to it, if you don't select any portion in the line, your editor will copy/cut/paste the whole line including the line break.

2️⃣ Comment and Uncomment Lines

Comments are extremely handy for us, but instead of going to each and every line individually and commenting it, just highlight whatever lines you want commented and then hit

Ctrl + /

This command will comment and uncomment the entire line

3️⃣ Search for a file in your file

Navigating through a project can get hard, especially when the project is pretty big. You can just use

Ctrl + P

to search for any file in your whole project.

4️⃣ Search for a keyword in a file and in the whole project

Searching for a keyword inside a file can be done using

Ctrl + F and then pressing Enter will let you navigate through the keywords

To search in the whole project,

Ctrl + Shift + F is used.

5️⃣ Indent and Un-indent code

Select the code block that you need to indent and then press the Tab key to indent the whole code block.

Similarly, to un-indent the code block, select it and press Shift + Tab

6️⃣ Create a new file

This might not be the most useful shortcut in bigger projects but you can create new files using

Ctrl + N

7️⃣ Create a new line

Usually, when we have to create a new line, we place our cursor at the end of the line and press Enter, but pressing

Ctrl + Enter

will create a new line just below the line where your cursor is present.

8️⃣ Navigate across the whole word rather than a character at a time

Ctrl + Arrow Key will allow you to navigate across a whole word at a time as compared to just a character

Ctrl + Backspace will allow you to delete a whole word at a time

9️⃣ Highlighting characters and words

Holding down Shift key and pressing allow keys will allow you to highlight characters.

Similarly,

Shift + Ctrl + Arrow keys will allow you to highlight a whole word at a time.

1️⃣ 0️⃣ The OG Shortcuts

Ctrl + S -> Save the file

Ctrl + A -> Select All

Ctrl + Z -> Undo

Ctrl + Y -> Redo

These are all the shortcuts you'll need to speed up your coding. Initially, it might be a little bit difficult to use them regularly.

You need to use these shortcuts consciously and in no time they'll get into your habit without you even knowing.

Top comments (22)

Collapse
 
pengeszikra profile image
Peter Vivo

Shortcuts always helpful,
alt + arrow :: line or selected up or down
alt + shift + arrow :: copy line or selected up or down

By the way I never use mouse in my MacBook Pro 13 because touch bar is very smooth even the fast and precise momentum driven scroll up and down : best for take look the code.

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Thank you for adding these Peter

Collapse
 
itr13 profile image
Mikael Klages

One almost universal shortcut I use a lot is "Move from end of line to next/prev end of line". It's right up left to go up a line, and right down left to go down a line

Collapse
 
dima000 profile image
Dumitru Motpan

It's a nice trick, quite handy.
The same can also be achieved with the Home and End buttons.

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Yes, it's awesome

Collapse
 
najsurf profile image
Łukasz Jóźwiak

Also one of the less known shortcuts is shift + alt + o to organize imports, very cool to use

Collapse
 
shubhracodes profile image
Shubhra Agarwal

I haven't heard of it, I'll try it out for sure

Collapse
 
ceoshikhar profile image
Shikhar

Vim or NeoVim FTW

Collapse
 
ful1e5 profile image
Kaiz Khatri

Absolutely legend

Collapse
 
shubhracodes profile image
Shubhra Agarwal

haha yes

Collapse
 
aneeskodappana profile image
Anees Kodappana

Ctrl+Enter is something new, thanks for sharing

Collapse
 
shubhracodes profile image
Shubhra Agarwal

You're most welcome Anees

Collapse
 
drsimplegraffiti profile image
Abayomi Ogunnusi

I use home and end keys to navigate to the beginning and end of lines respectively

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Yes, that's a great way!

Collapse
 
zaki_dz profile image
Zaki_Dz

In number 8 just correct world to word.
and thank you .

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Thanks a lot for pointing it out🙏

I'll correct it.

And I'm glad you liked it

Collapse
 
barungh profile image
Barun Ghosh

Readers of this blog post will move to Vim/Neovim in next few years 😎

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Hahaha😂

Collapse
 
dima000 profile image
Dumitru Motpan

PageUp and PageDown are also really usefull when you want to get to the end or the start of a file.
It also becomes really handy when navigating webpages. When reading manwha for example :)

Collapse
 
shubhracodes profile image
Shubhra Agarwal

Yes, Page up/down buttons are underrated

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Might want to list the Mac shortcuts too

Collapse
 
shubhracodes profile image
Shubhra Agarwal

These work for Mac too, just replace Ctrl with Command