Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Custom Keybindings Add-In for Microsoft Visual Studio

0.00/5 (No votes)
24 Feb 2002 1  
Store custom keybindings in ascii file and transport between workstations.

CustomKeys add-in, source code, and documentation is Copyright � 2002 The Programmer�s Toolbox.

 

CustomKeys Help

 

License

You may distribute the CustomKeys binary freely, provided this notice and all other copyright notices remain intact. The Programmer�s Toolbox retains all Copyrights. You may not sell CustomKeys for any reason. Source code is available from http://www.TheProgrammersToolbox.com.

 

Overview

CustomKeys was developed to deal with some rather irritating problems in Microsoft Visual Studio 6.0. For one, I often work at numerous development workstations. There is no good way to transport my customized keybindings between these machines. As a long time Emacs user, I am used to being able to customize my keybindings and use them across various workstations. Another problem is that MS Visual Studio has this nasty habit of trashing keybindings, but only after you set them all up. Also, in our lab, 4 or 5 developers may use a workstation. It would be nice to allow each one to maintain his own customizations and switch easily between them. For these reasons, I wrote CustomKeys. CustomKeys provides the following feature set:

 

  • Stores keybindings in a regular ASCII text file.
  • Allows you to easily switch between different bindings files.
  • Allows you to transport customizations between workstations very easily.
  • Will not trash your bindings like MS Visual Studio.
  • You can call VB macros, other add-in commands, or any other available command.

 

Installation

Most add-ins are dll�s stored in the Visual Studio add-ins directory. By default this is:

C:\Program Files\Microsoft Visual Studio\Common\MSDev98\AddIns

But, you can put the CustomKeys dll and help file anywhere you want.

1)       Start up Visual Studio.

2)       On the menu bar click Tools | Customize. The Customize dialog appears.

3)       Select the Add-ins and Macro Files tab.

4)       Click the Browse button in the lower right corner and navigate to the directory where you placed the CustomKeys dll and help file.

5)       Click the drop down list labeled Files of Type and change the filter to Add-ins ( .dll ) The CustomKeys file is now visible.

6)       Select the file and click Open. The dialog should disappear. You are back looking at the Customize dialog. The CustomKeys Add-in is now listed and the box should have a checkmark in it.

7)       Click Close. The Customize dialog disappears and the CustomKeys toolbar is visible. Drag this toolbar wherever you like.

 

CustomKeys is now installed on your system.

 

Usage

The CustomKeys Add-in exposes four commands:

 

LoadBindings - Forces a refresh of the CustomKeys data file. The only time you should ever need to do this is if you edit the bindings file manually.

 

KeyFileMaintenance - Brings up the main dialog through which you can insert, update, and delete key bindings.

 

WhatIsCustomKey - Tells you what command is bound to a specific key combination.

 

TranslateAndExecute - This executes the command associated with a custom key combination.

 

The typical way to use CustomKeys is to use MS Visual Studio�s keybinding facility to bind just one method � TranslateAndExecute. I bind this method to Control � X. Although this binding is normally bound to Cut, I then simply rebind the X key to Cut. So, to do a Cut, I have to hit Control � X X.� It�s worth it to me because Control � X is an easy key combo, which then gives me access to all my other bindings. The only limitation in CustomKeys is that only Control, Shift, and keys A � Z are available for custom bindings. That still gives a lot of combinations, and they won�t interfere with the MS default built-in bindings. For instance, MS maps Control � S to Save. I like S for incremental search ( Another Emacs thing! ). So, to do an incremental search, I bind the S key to the built in command SearchIncremental. Now, to perform an incremental search, I hit Control � X S. Pretty cool. Another one I like is Control � X Control � B. In Emacs, this brings up the buffer list. I bind Control � B to WindowList. When I hit Control � X Control � B I get the window list containing a list of all my open files.

 

Remember � My personal preference is to bind Control � X to TranslateAndExecute. You can use anything you want. To use CustomKeys, you must first call TranslateAndExecute, then your magic key combo. Notice how in my examples I always prefixed my custom keybindings with Control � X.

 

Here�s a list of all the controls and what they do.

 

Toolbar Buttons

There are three buttons on the CustomKeys toolbar. ( The tooltips will give you the command name )

 

LoadBindings - Clicking this button forces a refresh of the CustomKeys data file. The only time you should ever need to do this is if you edit the bindings file manually.

 

KeyFileMaintenance - This button brings up the main dialog through which you can insert, update, and delete key bindings.

 

WhatIsCustomKey - This button will tell you what command is bound to a specific key combination.

 

Dialogs

 

File Maintenance Dialog

 

 

 

Insert - Brings up a dialog where you can add a new custom keybinding. Note that command names are case sensitive and must be entered correctly.

 

Update - Allows you to edit the currently selected binding in the list.

 

Delete - Deletes the currently selected binding from the list.

 

SetFile - Allows you to specify the keybindings file to use. If the file you enter does not exist, an empty file will be created for you.

 

If you have questions or comments about CustomKeys, drop me an email at feedback@TheProgrammersToolbox.com. Also, be sure to check for the latest version periodically at http://www.TheProgrammersToolbox.com.

 

CustomKeys add-in, source code, and documentation is Copyright � 2002 The Programmer�s Toolbox

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here