The most useful key on your keyboard: TAB

It has occurred to me that not everyone has been using a command line since the DOS era. Some may have only encountered the command line very recently as they make their first steps into data analysis.

This one is for you new people. This is the most important thing you should now if you want to survive on the command line. You don’t need to type as much as you think you do! Introducing the most worn out key on my keyboard: TAB.

At any time you are on a command line, you can hit the TAB key on your keyboard and the computer will try to be clever and finish what you were trying to type.

Whenever you press the TAB key, the computer will compile a list of things that start with what you’ve already typed and show it to you. For example, here is a folder with a couple of files:

$ ls
file_1
file_2
file_3
important_document.doc
Letter to my guinea pig.docx 
recipes.txt

Here is a scenario that would be a nightmare without the TAB key. I want to copy the file /home/marijn/Documents/Brain Research Unit/Thesis_v2013-04-23-revised_v2_OK_final.doc to a new location, say /home/marijn/Dropbox. Here’s how you could do it (when I write <TAB>, I mean press the TAB key):

$ cp /ho<TAB>/ma<TAB>/Doc<TAB>/Br<TAB>/Thes<TAB> /ho<TAB>/ma<TAB>/Dro<TAB>

Yes, I use the key a lot. I almost never fully type out anything, but instead rely on the so called TAB-completion to do its job.

Getting a list of options

If the TAB key cannot fully complete your command, it will complete as much as it can and then stop. Pressing the TAB key again will result in a list of all possible continuations. This is insanely useful.

But wait, there’s more!

The TAB key also works in your text editor while programming! (If it doesn’t, you should really go and find a real text editor.) So there’s actually no reason not to give variables or functions long names like correlation_between_conditions or something, because all you will type from now on is `cor<TAB>`.