Rely On Your Keyboard
I forget sometimes how much I rely on the keyboard to select and manipulate text as a software developer. It makes me very productive simply because I take less time to get work done. I encourage all developers to rely on their keyboard more and their keyboard less.
I spent time this past weekend using a hand saw to cut a fallen branch down to smaller pieces so I could move them to my burn pile. It was a lot of hard work using the hand saw. If only I had a chain saw. It would have made the job so much easier and it would have taken a fraction of the time. As my father always says, “for every job there is the perfect tool.”
I see the same situation quite often when I see developers use an IDE, like Visual Studio, to code software. They rely heavily on the mouse to click and select text and to modify the code. This is the equivalent of cutting a tree by hand. I wonder how much more productive developers could be if they had the equivalent of the chain saw. Enter, keyboard shortcuts.
So much of what we do as developers involves creating and manipulating text. It makes sense for us to be a efficient as we can be to maximize the amount of work we can get done in a given time. Using your mouse to navigation around and to select text is very slow compared to using text shortcuts. If you want to be a better programmer, then learn to rely on the keyboard more, and less so on your mouse.
The Basics
Here are some basic keyboard shortcuts I would want all developers to learn. Once one has mastered these shortcuts, I guarantee you’ll be able to get more work done in less time.
Full disclosure, these are for Windows only. But you should be able to find the equivalent shortcuts on other operating systems as well since the vast majority of these are the same everywhere.
Selecting Text
I have used these shortcuts for so long they are second nature to me. Note that the selection will always start wherever the cursor is located.
Selection | Shortcut |
---|---|
Select the text to the right (1) | CTRL + SHIFT + RIGHT ARROW |
Select the text to the left (1) | CTRL + SHIFT + LEFT ARROW |
Select the current line of text | SHIFT + DOWN ARROW |
Select the preceding line of text | SHIFT + UP ARROW |
Select to the beginning of line of text | SHIFT + HOME |
Select to the beginning of the file | CTRL + SHIFT + HOME |
Select to the end of line of text | SHIFT + END |
Select to the end of the file | CTRL + SHIFT + END |
(1) Depending on the editor, the selection will stop at the first white-space character or non-alphanumeric character.
To select multiple times, hold down SHIFT or CTRL + SHIFT, and press the arrow key multiple times (or hold the arrow key down to select more quickly).
Manipulating Text
CTRL + C
Copy
CTRL + X
Cut
CTRL + V
Paste
CTRL + Z
Undo
CTRL + Y
Redo
These are pretty much universally supported in every editor, IDE and operating system.
Navigation
Movement | Shortcut |
---|---|
Move Up | UP ARROW |
Move Down | DOWN ARROW |
Move Left | LEFT ARROW |
Move Left by one word | CTRL + LEFT ARROW |
Move to the beginning of the line | HOME |
Move to the beginning of the file | CTRL + HOME |
Move Right | RIGHT ARROW |
Move Right by one word | CTRL + RIGHT ARROW |
Move to the end of the line | END |
Move to the end of the file | CTRL + END |
Again, holding down the arrow key will make the navigation move more quickly.
Your Favorite Text Editor
You don’t have a favorite text editor? I would urge you to find one. Mastering all the keyboard shortcuts in a particular Text Editor can be one of the most important skills you can ever have.
Not only should you learn to select and manipulate text, you should also learn master the way the text editor allows you to find and replace text, have multiple files open at the same time, navigate between all the open files, etc.
As an example, one universally supported navigation shortcut is CTRL + TAB
. It switches to the previous tab in a multi-tab user interface. Works in every text editor I’ve ever used, every IDE, even most web browsers support this shortcut.
Learn Your IDE
Each IDE is different, however you will find that most (if not all) will support default keyboard shortcuts for most of its popular tasks. And allow you to assign custom keyboard shortcuts and modify existing ones.
The reason shortcuts are so widely supported in IDEs is no accident. Developers will expect this high level of support for shortcuts. It makes them more productive and who doesn’t want to be more productive?
Summary
Keyboard shortcuts make you more productive. Learn them, practice them, master them.