Keyboard shortcuts for tech-savvy journalists
NOTE: Originally published on knightlab.northwestern.edu by student fellow Suyeon Son.
Rebecca Lai watches me type every letter of a long file name — something likepythonreallylongfilename1234567.py — into Sublime. After the first couple letters, she cannot contain herself.
“TAB COMPLETE! TAB COMPLETE!”
If there’s an apt analogy for the way Lai must feel when I forget to tab complete (keep reading if you’re unfamiliar with the term) as she helps debug my code, it must be something like this: you’re watching over your mother’s shoulder as she begins to Google something. She moves her mouse over to the search box. She clicks in the box to make sure, yes, the cursor is blinking there. She types in a search term. She moves her mouse over to the “search” button. Then, finally, she clicks. Sweet release.
Why? Why would you do that?
Because she doesn’t know any better. And sometimes neither do I.
Some bits of wisdom are learned out of necessity, like when you’ve pored over your Macbook keyboard only to realize there’s no PrtScn key like you’d find on a PC (⌘ + ⇧+ 3 or 4, if you want just a selection of the screen). Others are barked at you until you comply.
The thing with keyboard shortcuts is that sometimes, you don’t even think to figure out if one exists. Tab completion is a good example. Microsoft Word doesn’t let you tab to complete a word or phrase just because you’ve already established it in your header. But Sublime Text does; you’d just never know it unless someone told you.
Of all the keyboard shortcuts that exist, the ones below are what I’ve found to be the the most valuable, especially for someone constantly switching between editing articles and editing code.
Tab
Let the computer finish that string for you.
Works in: Terminal, Sublime
⌘ + /
Is this the offending bit of code? Or this? Comment out all the lines at once.
Works in: Sublime
↑
To avoid rewriting the command you just wrote, use the up arrow. Keep pressing up to bring up even older commands you wrote.
Works in: Terminal
⌘ + C
You’re probably thinking “duh, everyone know how to copy text.” You might be pleased to know, however, that if you don’t have text highlighted, this shortcut will copy the current line your cursor is on.
Works in: Sublime
⌘ + X
If you don’t have any text highlighted, this shortcut will cut the current line your cursor is on.
Works in: Sublime
⌘ + D
Select the current word your cursor is on.
Works in: Sublime, word processors
Option + ← / →
Move cursor to beginning or end of word.
Works in: Sublime, word processors
⌘ + ← / →
Move cursor to beginning or end of current line.Sublime, word
Works in: processors
Alt + Shift + ← / →
Select text a word at a time.
Works in: Sublime, word processors
Shift + ← / →
Select text a character at a time.
Works in: Sublime, word processors
⌘ + Shift + ← / →
Select text from current cursor position to beginning or end of current line.
Works in: Sublime, word processors
⌘ + Shift + ↑ / ↓
Select text from current cursor position to beginning or end of document.
Works in: Sublime, word processors
Esc + B / F
Move cursor from argument to argument.
Works in: Terminal
Control + A / E
Move cursor to beginning or end of command.
Works in: Terminal
Control + U
Clear line.
Works in: Terminal
Control + W
Delete word before cursor.
Works in: Terminal
Keyboard shortcuts longer than two keys at a time have taken me a little more practice than others to program into the brain hardware. But as numerous journo-hackers have told me, they always appreciate a savvy individual who knows his or her away around a computer, and that includes being able to navigate text editors without relying on clicks. Plus, I welcome anything that saves me from the awkward moments of silence between a mentor and me as I struggle through demonstrating broken code.
NOTE: This piece was originally published to Knight Lab’s site and is here as an experiment. Be sure to check out some of Northwestern U.’s free tools for journalists and digital storytellers: JuxtaposeJS (pre-release), StoryMapJS and SnapMap, as well as SoundCiteJS and TimelineJS.