Got Filename Completion?

December 28, 2004

In my travels visiting various projects, I continue to meet developers wearing out their fingers in the Windows command shell. Just watching them type (and re-type) all those file/directory names character by character is like nails on a chalkboard to me. Growing up on UNIX, I can't imagine life without filename completion. It's another one of those things that computers are good for. Yet I'm surprised that many good developers still don't know it's possible on Windows. (Don't ask why it's not set by default.) So here goes...

Filename completion is your friend. You simply type the first few characters of a file or directory, then hit the filename completion key (TAB). The computer then uses its noggin to figure out which file/directory you're referring to and completes the rest of the word. If the characters you enter match multiple files or directories, then continuing to hit TAB will cycle through the choices. It adds up to a whole lot less typing in the long run and you don't have to remember the exact spelling of names.

Here, just look at how lazy I am. I wouldn't dream of typing

cd c:\myBigFatProjectName\tests
when I can coast through the file system like this:
cd c:\m<tab>\t<tab>

Ah. No more chalkboard noise. Life is good. We might actually get some code written today.

Here's how to turn on filename completion in Windows:

  1. Start the registry editor (regedit) and use Edit->Find to locate the CompletionChar registry key (or navigate to HKEY_CURRENT_USER\Software\Microsoft\Command Processor)
  2. Change the CompletionChar registry key value to 09 (the hexadecimal value of the TAB key)
  3. Restart any open console windows

Note: UNIX veterans will be quick to note that the Windows rendition of filename completion has some shortcomings. For example, you have to type in file separators (\) for it to continue walking down a directory structure. Then again, you're all probably using cygwin with a real shell.

So, I'll continue to spread the word whenever I hear that screeching noise while wandering around projects. In the meantime, take the opportunity to wander around your own project. Watch what other folks do. You'll be amazed at what you can pick up just by shoulder surfing. When I was learning to snowboard, I'd wait for another rider to come by and then try to follow their line down the mountain. Everyone rides with their own style and shadowing a lot of different riders helped me learn much faster than I would have alone.

Read more posts in the blog archive »