Windows 7 / Getting Started

Enabling Directory Name Completion

As mentioned in the previous section, filename completion is enabled by default-the Tab key searches for a filename or folder name matching the characters to the left of the cursor. A similar feature called directory name completion lets you use a different key to match only directory names.

I will show you how to enable directory name completion shortly, but prepare yourself for some strangeness. First, there's the matter of the odd default control key settings:

  • By default, name completion is enabled and uses the Tab key, whereas directory name completion is disabled.
  • If you run CMD with /f:on on the command line, name completion is enabled but now uses Ctrl+F. Directory name completion is enabled and uses Ctrl+D.
  • If you run CMD with /f:off on the command line, both name and directory name completion are disabled.

If you want directory name completion to be enabled all the time on Windows XP, the easiest approach is use the TweakUI tool, which you can download from setting is on the Command Prompt tab.

You can also edit the Registry to change the default settings on XP,Vista, or Windows 7.The values CompletionChar and PathCompletionChar set the key codes used for name completion and directory name completion, respectively. CMD looks for the values in the key

HKEY_CURRENT_USER\Software\Microsoft\Command Processor

which holds the settings for the current user. If they are not present there, CMD looks in

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor

which sets the default for all users.

CompletionChar and PathCompletionChar are DWORD values that hold a number representing the associated control key. It's easiest to enter these values in decimal, where 1 = Ctrl+A, 2 = Ctrl+B, ... 26 = Ctrl+Z. Some handy values to know are listed here:

Value 	Key
4 	Ctrl+D
6 	Ctrl+F
9 	Ctrl+I (Tab)
32 	Disables completion

To use Ctrl+F for name completion and Ctrl+D for directory name completion, follow these steps:

  1. Run the Registry editor with the command regedit.
  2. Open HKEY_CURRENT_USER and find Software\Microsoft\Command Processor.
  3. Double-click the already-present CompletionChar entry, click Decimal, and enter the number 6. Click OK.
  4. Select Edit, New, DWORD Value.Type the name PathCompletionChar.
  5. Double-click the new entry, click Decimal, enter the value 4, and click OK.
  6. Close the Registry editor and any Command Prompt windows.

From now on, when you start a Command Prompt window, Ctrl+F and Ctrl+D will work.

So you don't get surprised by CMD's behavior at some later date, when Registry settings have been made, CMD follows these rules for enabling name or directory name completion:

  • If the Registry value is between 1 and 26, completion is enabled unless you specify /f:off when you run CMD.
  • If the Registry value is 32, completion is disabled regardless of the /f option setting.
  • If the CompletionChar value is defined as 9 (Tab) and the PathCompletionChar value is not defined, CMD displays the default behavior described earlier.

Now, back to our discussion of how the command prompt environment works.

[Previous] [Contents] [Next]