Investors in Keystrokes 👨‍💻

So when this lockdown started, i figured instead of just watching more box sets or playing games, i should maybe try and learn something new, or at least make myself more efficient at something.

After getting slightly obsessed with keyboards (more on that in another post) I started wondering how people could actually be  productive with a 60% keyboard, that got me thinking more about keyboard shortcuts.

I thought about how sometimes you watch someone writing code, and they never seem to go anywhere near the mouse, they just float across the keyboard like a person possessed, and figured that might be an area I could actually improve on.

Lets go old School 🖥️

Even though I do 95% of my work in Visual Studio and VS Code I did (for about a day) have another go at trying my hand at VIM.  Now, I do kind of know how to use VIM, when i'm in a Linux shell I do tend to use it to edit files, but i'm not that profeicant in it. So, I installed the plugins for VS Code and starting trying to get the hand of it. I lasted about 2 days and just ended up turning it of again. My brains to used to using the arrow and ctrl keys, and thats not really how VIM works. Ok, back to the drawing board.

Working with what you already have

After abandoning VIM, I figured i'd just try and learn some more of the default keyboard shortcuts my editors of choice had built in. Now there are 100's, and you can if you want make your own (more on that later), but there a few I came across that I now find myself using everyday. Not sure how i missed them to be honest.

Ctrl + Tab - Ok, this one is so obvious now I don't know how i missed it. This opens a list of all your open tabs and lets you flick between them.

Ctrl + T - I've been using this one for a while, lets you start typing to find a class/file/method and jump right into it

Ctrl + End/Home - Jump to the start or the end of the open file. Just using Home or End will take you to the end of the current line

Ctrl + Shift + P - In VS code this opens the command pallet, where you can run various command from. I use this a lot if i copy a file in to change the language mode and format the text

Ctrl + Left/Right - Use this to skip words whole words to the left and right. If you also combine it with Shift you can select the words as well

Alt + Enter - This was a bit of a game changer as well. In Visual Studio when you get the dreaded red squiggle under something, place the cursor over the word in question and this keypress will open up the quick actions menu to let you fix it, or give you hints on what to do

Those are the main ones I've started using, and I do feel like its making me code a lot quicker, not quite coding at the speed of thought, but faster than asthmatic ant with some heavy shopping like i was before.

Knocking it up a notch

As i said before, I did try VIM for a couple of days, but just couldn't get used to it. I was a bit annoyed with myself as there's a lot to like. One of the main functions was to be able to easily delete or change a word. I found myself used the CW and DD commands all the time.

So thats obviously not going to work in the normal world of Visual Studio, but I did find there was a couple of shortcut keys to delete the word to the left/right of the cursor, and to delete the current line. By default these were bound to some keys already, but it made more sense (at least in my head) to bind them to alternate keys that mirrored VIM.

So, with that in mind, i fired up the keyboard shortcut settings in VS code (Ctrl+K Ctrl + S), found the commands I needed and re-mapped them to some new keys, like so

Delete word to left, command deleteWordLeft new binding Ctrl+D Ctrl + R
Delete word to right, command deleteWordRight new binding Ctrl+D Ctrl + W
Delete line, command Delete Line new binding Ctrl+D Ctrl + D

If I come across any others of use, or update my prefs with something else VIM like i'll update this post

Visual Studio Code Key Bindings
Here you will find the complete list of key bindings for Visual Studio Code and how to change them.
VSCodeVim/Vim
:star: Vim for Visual Studio Code. Contribute to VSCodeVim/Vim development by creating an account on GitHub.