the crutch of any bash, tcsh, or ncftp user. the notion of typing the first few letters of a file or directory and then hitting tab to complete it.

cd /u(tab)X(tab)li(tab)X1(tab)fon(tab)mis(tab)

added note:
zsh has this functionality, much more to a sophisticated standpoint, to the point where it will complete based on whats already been typed on the command line:
In a directory with:

If one were to type:
tar zxvf foo(tab)
zsh will complete to the tarball's filename, as opposed to pausing at the common foo-1.2 of the dirent. This is configurable.

Tab completion is for wusses. Sure, I use it, but only when I have no choice. Most of my day I'm in XEmacs, where I've bound M-/ to hippie-expand.

Even the default binding for M-/, dabbrev-expand, is pretty scary. It searches the entire buffer (optionally, buffers) for a completion to the word you just typed in.

But what if you want to complete a file name instead of a word? Or an entire line or balanced braces construct (according to the buffer's rules)? Across this buffer and all other buffers? hippie-expand does all this (and more) for you! It searches for all these types of completions, presenting them according to a list of completion types.

And you can write your own Emacs Lisp functions to get yet more completions. But I'm not that far gone. Yet.

In the bash shell under Linux and other Unixesque operating systems, tab-completion allows users to quickly type the name of a command, or to find out the name of a command from its first few letters.

If there are no spaces in the command line, then the text that is being tab-completed is assumed to be a command. If the command has only one possible completion, then pressing TAB once will complete the command. If not, but the next few characters are shared, it will complete those. If it cannot complete any characters, it will display a list of all valid commands matching the criteria after a second press of TAB: if there are an excessive number, it will ask for confirmation first.

If there is a space, it is assumed that the user is trying to type the name of a file or directory: the same rules apply. This means that a directory structure such as /usr/doc/perl/perl6/TODO.txt can be typed as /utab/dtab/petab/ptabTOtab... a much quicker way when you know it will work.

To enable tab completion in Windows 2000 (and maybe NT), grab a recent copy of Tweak UI. You can set command line completion to work with a variety of keys, including tab. Very useful if you have to use Windows at work, but you're used to CLI completion at home.

Tab completion in Windows NT & 2000

For the souls that balk at using such a user-friendly piece of software as Tweak UI, here's the way to enable tab completion on your Windows NT or 2000 box using direct registry editing. If you don't know how to edit the registry directly I recommend you do get Tweak UI and not muck about in this database from hell thought up by the folks at Redmond.

So, open up your favorite registry editor and go to HKEY_LOCAL_MACHINE for a system-wide implementation or HKEY_CURRENT_USER for a per user implementation. Note that the per user setting takes precedence.

Then go to

      /Software/Microsoft/Command Processor

If there is already a key named CompletionChar then just change the value for the key to whatever you want. See below for possible values. If the key is not yet in existence, then add a value of REG_DWORD named CompletionChar and set the value.

Now, for Windows NT you're done (well, not exactly: you need to reboot).

Windows 2000 recognizes another key named PathCompletionChar, also a REG_DWORD. This would apparently enable path completion, with the value for CompletionChar enabling filename completion. So what's the difference? I don't know and frankly don't care. I have set both of these keys to 9, which put the completion under the trusty TAB key. I have enough trouble remembering not to use / when CD'ing under Windows.

Possible values

A value of 0 or the absence of the key turns off completion completely.
A value in the range of 0x1 to 0x1F sets completion to the ASCII control character of that value. Use 9 for the TAB key.

Differences with Linux

When you press the file or path completion, the first matching entry appears. So, no list. Pressing it again retrieves the next entry in the list. To go backwards, press SHIFT-{completion-character}.

Using completion only once (why?)

You get the ability to enable completion on a per use basis under Windows 2000. Just add the switch '/F:ON' when using CMD. This sets the completion chars to CTRL-F for filename completion and CTRL-D for path completion, so I don't really know what use this could be.


April 26, 2001

Log in or register to write something here or to contact authors.