Cursors, shortcuts and clipboards; increasing your productivity
Tags: productivity, beginners
Published: 2022-12-21 12:54:58

Save time. Increase productivity. Here are several small things that will make you a bit faster, and your work a bit more enjoyable. I hope you'll pick up at least one or two things. You can go wild and use all of these. It's a good start if you want to progress into a real power user.


**Notes:** 
* Several GIFs ahead. Just click on it to stop it looping.
* Hotkeys used are for MacOS, but if you replace <kbd>⌘</kbd> with <kbd>ctrl</kbd> you should be all set for Win/Linux.

## Use your cursors wisely

The same way a craftsman uses his hands as tools in the physical world, we use our mouse and keyboard as a tool in the digital world. It may not be our most important tool, but nevertheless as a tool we should be always looking to improve how we use it. 
  
### Copy a single line
Everyone knows how to copy a line right? (<kbd>⌘</kbd> + <kbd>C</kbd>)

Some might not know that you don't need to go through the pain of highlighting a line in order to copy it. Put the cursor anywhere on the line, hit the shortcut and the line will get copied.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oewzp5r2xt0cwz93zbeq.gif)

People struggle clicking three times to highlight the line, sometimes they click the fourth time, highlighting the whole text. Or they drag the cursor along the line usually messing up the highlight or end up missing a couple of characters.

Place the cursor in position and hit that shortcut!


### Remove a single line
The same cursor placement magic that applies when copying a line also applies when removing a line. The quickest way to remove a line is placing the cursor anywhere on that line and hitting <kbd>⌘</kbd> + <kbd>X</kbd>.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8xyke3jyzq0klybr054.gif)
One thing to note here is that <kbd>⌘</kbd> + <kbd>X</kbd> cuts the lines, it does not delete them. So it affects your clipboard, or the clipboard manager that you use. You do use a clipboard manager right?

If you actually want to delete the line then you should use a different shortcut, <kbd>⌘</kbd> + <kbd>shift</kbd> + <kbd>K</kbd>. The shortcut is for VS Code, it might differ for other IDEs.

Since the above shortcut is a bit harder and takes a bit more time to perform than the one for cutting, my preference is <kbd>⌘</kbd> + <kbd>X</kbd>.

### Multi-cursors
Place one cursor to edit a single line, place multiple cursors to edit multiple lines! Multi-cursors are your friends for fast simultaneous edits.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mx815khu3151vws5le9g.gif)

Once you get a hang of it you'll love it as it makes coding a lot more fun. The two main shortcuts are <kbd>⌘</kbd> + <kbd>D</kbd> which selects the word at the cursor, or the next occurrence of the current selection, and <kbd>Alt</kbd>+ <kbd>Click</kbd> that adds secondary cursors.

This was a game changer for me, and I used it on a daily basis. I seriously recommend you learn the basic shortcuts and give it a go.

This is something all popular Integrated Development Environments have, [VS Code](https://code.visualstudio.com/), [JetBrains](https://www.jetbrains.com/) IDE's, [Atom](https://atom.io/), [Sublime](https://www.sublimetext.com/) so you can definitely try it out.

## Clipboard manager
Now that you know how to copy lines more easily and know how to add a bunch of cursors and copy all the lines at once, you need a better storage place for the data you copied. Instead of overwriting what you copied with each new copy, a clipboard manager enables you to store the data you copy.

>Copy from the browser, switch to the IDE to paste, then go back to the browser to copy again, switch to the IDE to paste, go back to... **no more!**

Copy all the things you need from the browser, switch to your IDE and paste one by one in the desired location.
While on Windows I used [Ditto](https://ditto-cp.sourceforge.io/) as it has several cool features. On MacOS I use [Pastebot](https://tapbots.com/pastebot/) which also comes with some advanced features. One of the features I use is Custom Pasteboards where I keep a permanent [Lorem Ipsum](https://loremipsum.io/) paragraph which is always useful to have at hand while developing and testing. I also keep my personal Zoom link there as well as it makes setting up meetings on the fly easier. If you find yourself using something over and over again and it might fit into a persistent pasteboard, add it (don't add passwords tho)!

## Navigating through the codebase

**Use <kbd>⌘</kbd> + <kbd>P</kbd> to quickly open a file.**

Don't start looking for the file in the IDEs file Explorer, opening and closing different folders trying to locate it. Or even worse, using the global search to search for something you know is in that file, just to open it.  This is something I have witnessed first hand, and usually gets me agitated :)

Pretty much all of the modern editors have this documented in more length. Two main actions follow.

### Open a file
You can open any file by its name when you type <kbd>⌘</kbd> + <kbd>P</kbd> (Quick Open). As you start typing the IDE will narrow down the list of files from which you can select to open. You don't have to go to the File Explorer and dig up a file.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4brq78exh586vbvwkbdd.gif)

### Find a symbol or jump to a line
Use <kbd>⌘</kbd> + <kbd>P</kbd> and append <kbd>@</kbd> to find  a method inside the file. You can also combine <kbd>⌘</kbd> + <kbd>P</kbd> with <kbd>@</kbd> and/or <kbd>:</kbd> to easily jump to methods, variables or jump to lines. I usually use it to jump to a line, especially if I see the line mentioned in the error stack trace.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n2ruwyyp4bjla2fyxzuz.gif)


### Jump to definition
**Use your mouse keys.**

You can jump to definition with <kbd>⌘</kbd>+ <kbd>Click</kbd> , but you cannot jump back. Once you jumped in, the only way to go back is to navigate back with <kbd>⌘</kbd>+ <kbd>-</kbd> . At that point if you need to see the definition once more, you can just navigate forward using <kbd>⌘</kbd>+ <kbd>shift</kbd> + <kbd>-</kbd>. 
>Jumping in several definitions consecutively and then navigating back and forth between them to better understand the data flow in yours or someone else's program is something you have to get familiar with.

The shortcuts here are quite impractical. Of course you can change the shortcuts to your liking. But the neat thing here is that you can also use your mouse to navigate. You just need a mouse with two additional keys which are usually by default bound as navigational keys. You can then use those keys to navigate between the methods in your IDE. And since jumping in requires a mouse click, it feels natural to continue to navigate using the mouse keys.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lqiutz380m215rouarxa.gif)

Even if you don't want to use your mouse keys, do learn the shortcuts or change them as you like. Any of the above is better than navigating back by trying to find the file that you just jumped out of in the list of your currently opened files. The shortcut is a lifesaver here.

These are only bits and pieces I picked up in my own journey that made it a bit more fun, hope it will do the same to you. They might not seem much but as the years go by they will add up.