How do I record a Visual Studio macro to set Options settings?
I've just tried to record a macro to help me switch word-wrap in editors on and o开发者_StackOverflow社区ff quickly, but all the macro records is DTE.ExecuteCommand("Tools.Options")
, which leaves me with a big, dumb open dialogue when I try and execute the macro.
How can I record or write macros to help me quickly set options, without the rudeness of the modal options dialogue? Are there any extensions I could use for this?
For a bonus point, is there a way I can automate Options changes without using macros, and without having to write a big VS extension?
switch word-wrap in editors on and off quickly
Maybe I'm confused, but word wrap is toggled by Ctrl-E, Ctrl-W
.
is there a way I can automate Options changes without using macros
You can use the Visual Studio command window here:
View > Other Windows > Command Window
In addition to the Visual Studio Commands list, you can enter any Menu command in the command window. I found Edit.ToggleWordWrap
, which toggles word wrap in the currently-focused text editor.
To bind a command (or several commands) to a shortcut key, create an Add-In (not a big VS extension ;). In your case, the relevant line would look like this:
cmd = cmds.Item("Edit.ToggleWordWrap", 1);
There's really no way to record a macro to set anything in the Options dialog. The macro recording infrastructure in general can't handle modal dialogs and essentially ignores them. The options dialog is no exception here.
The best hope here is to
- Save the options out to a vssettings file
- Hand code a macro which manipulates the low level IVs interfaces to set the options you want.
The vssettings file is the more viable, and far simpler, option
精彩评论