DEV Community

Cover image for KeyBoard Shortcuts
Brandon Briones
Brandon Briones

Posted on

KeyBoard Shortcuts

If you are just starting out in learning how to code, this will be a good read for you. The one thing that I wish I did early on when learning how to code, is taking the time out of my day to learn some keyboard shortcuts. Main reason for that is because we as developers are going to be spending a good amount of time in front of the keyboard. That being said, we want to use every keystroke as efficiently as possible. Otherwise there is going to be a lot of time just thrown to waste over time.

The shortcut keys below are the ones that I use frequently when working with vs-code. Some or all also apply to other code editors and if they don't just check the key bindings in your editor. Since I am on a Mac I'll be using Command but if you are on windows you can switch out Command for Control and Option for Alt and you'll be relatively safe.

Copy/Paste/Cut

The most common short cut keys that I'm sure everyone is aware of, is Command + C to Copy, Command + X to cut, and Command + V to paste. Now usually when you do any of these commands you highlight everything you want to copy then do the commands. Now let's say you want to Copy or Cut a specific line, there is no need to highlight that line! As long as the text cursor is on the designated line, Command + C will copy the whole line and the line break and Command + X will delete it.

Duplicate

In order to duplicate things we usually do the old copy and paste. A really easy way to duplicate something if you need multiple instances of the same thing is Shift + Option/Alt + Down arrow key. For a single line all you need to do is be on the line, but if it is multi-line then you will need to highlight.

Line movement

This next one is one of my favorites.
Option + Up/down arrow key, allows you to move an entire line up or down. This command also allows you to move all the lines you highlight up or down. This is very handy in many situations, either for rearrangements or you wrote the code in the wrong line and you just need to move it to where it needs to be. This will save you from having to copy, paste, and then cut.

Text cursor movement

When moving around through a line usually you just either click where you want to be or just move space by space clicking on the arrow key until you get to where you want to be. Well some quick hacks to moving all the way to the end of the line is by doing Command + right arrow key and
Command + left arrow key to move to the beginning of the line.
What if you don't want to do either and you want want to move a couple of words over? There's a shortcut for that too! On a mac it will be Option + left/right arrow key but for windows it will still be Control + left/right arrow key. This will save you so much time guaranteed.

Highlighting

The most common way to highlight is simply by left clicking and holding down until you have everything that you want. When using a mouse or touchpad sometimes the precision can be a little off or a lot. By using shortcut keys now you have another solution.
Simply by doing Shift + left/right arrow key you have the option to highlight letter by letter or
Shift + Option + left/right arrow key if you are going word by word. Depending on where you text cursor is located you can highlight everything in front or behind the cursor by doing
Shift + Command + left/right arrow key. Now if you want to highlight everything below or on top of the line that you currently are in,Shift + Command + up/down arrow key will do the trick. In the case that you don't want to highlight everything below or at the bottom just the one directly above or below simply do Shift + up/down arrow key.

For now these are all the shortcut keys that I will share, there is a lot more and I challenge you to explore and pick up some more. If you put them into practice every opportunity that you get, it will start becoming a habit and you won't even have to think twice about doing a particular action. Next thing you know people will be astounded by your mastery of the keyboard and will think that everything you do is MAGIC!!

Top comments (0)