开发者

Assigning keyboard shortcut to a macro in VS 2008

Rather a simple question, this one - but I've no experience with VS macros, and therefore my confusion.

I've copied this macro for line duplication to a new macro project, in a new module. The macro works; if I start it from wit开发者_StackOverflowhin a macro editor my line will be duplicated. However, I don't see how I can get it to appear in the Tools/Options/.../Keyboard shortcut list. Can anyone offer a helping hand with this one ?


Rather than adding a new macro project, open the Macros Explorer (View/Other Windows/Macro Explorer), and right-click on MyMacros and select New Module.

In the New Module dialog, enter the name "DuplicateLastLineModule". The module DuplicateLastLineModule then appears in the Macro Explorer. Double click it to open the macro editor. Replace the contents with the macro text from the blog you linked to. The key here is that the name of the module file should match that in the declaration "Public Module DuplicateLastLineModule"

Save the module.

From Visual Studio, open Tools/Options/Keyboard.

In the field "Show commands containing", type "Duplicate". You should see an entry in the list beneath reading "Macros.MyMacros.DuplicateLastLineModule.DuplicateLine". Select it. Click on the "Press shortcut keys" field and press the key sequence that you want to use to invoke the macro. Click OK.

From an editor window, type a line of text, and press your key sequence. The macro should then launch and duplicate the line.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜