Friday, October 18, 2013

ETB: Editing: Just 3 Shortcuts for Dramatic Efficiency Gain

Continuing on the Embracing The Beast (ETB) series, this time we're going to dive into the text editor.

If you edit at all like I used to, these 3 shortcut keys will save you a huge number of redundant keystrokes every single day.  Yep, just learning 3 new shortcut keys.

I'm not going to keep you waiting, here they are:
Shortcut Action
Ctrl+L Cut current line
Ctrl+C (with NOTHING selected) Copy current line
Ctrl+Enter Insert blank line above

I have learned tons of new shortcut keys since I started this process, but these three are the most important.  If you learn this and nothing else in this series, it will still be a marked improvement!

Why?  Let's take a look.

Cut Current Line
Like it says, this command cuts whatever line the cursor is on (meaning it copies it and deletes the line, including the carriage return).  You can use this to easily move a line up or down, or to just delete a line.  There is a command that deletes the line without cutting it (Shift+Del), but when you're just starting out it pays to limit the number of things you're learning all at once.  Ctrl+L does the same thing that Shift+Del does, and rarely will the difference ever bite you.  Start simple.

"Cool man, but like, why is this such an efficiency improving short cut?"

Glad you asked!  Here's the sequence of keys I used to hit to do the same thing Ctrl+L does in one keystroke:
  1. End
  2. Shift+Up
  3. Ctrl+X
3 keystrokes when I could have used 1!  Suppose you delete or move lines 100 times a day, which is probably crazy low.  You would save 200 keystrokes.  This paragraph is only 195 characters long.

Maybe that doesn't seem like a lot, but there is a hidden benefit here too; Ctrl+L is a single command that maps directly to a pretty high level action you wanted to take.  It may be only 2 keystrokes better than the more manual way, but you don't have to busy yourself thinking about the micro steps required to move the cursor and highlight text.  You just, BAM, do the action you want.  End. Of. Story.  Conceptual overhead here is much reduced!  

Copy Current Line
I used to do this the same as above, except I'd Ctrl+C instead of Ctrl+X.  But it turns out, if you just hit Ctrl+C when nothing is selected, VS will copy the entire line!  Brilliant!  

Suppose I copy half as many lines as I delete: 50/day =100 keys saved. This paragraph is 98 chars.

Add Blank Line Above
You might not think that you do this operation too often, but I think you'll be surprised.  How many times do you write a block surrounded by {}?  There are LOTS of ways you might do this, but the way I usually do it is I write the definition, the open {, and then the closing }, and now I want to go back up and type in the body, but I'm stuck below it!

Here's what I do:
  1. Up
  2. End
  3. Enter
That's 3 keystrokes again instead of just Ctrl+Enter!  Interestingly, this is the one I'm having the hardest time training myself to take advantage of.  That could be because how often I use it varies depending on what I'm coding, but I bet on a typical day I do this way more than I copy lines.  Lets go with 200 times a day, for 400 keys saved.  And you guessed it, this paragraph is 396 chars.

So with all three of these combined, and given my completely made up numbers, that's 700 keystrokes saved, every day, just by using these three shortcut keys,  That's clearly a good thing, but the real benefit is in the fact that you're now communicating with your editor on a higher level than just cursor up and down.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.