更新时间:2023-02-03 14:57:13
那总是让我很烦。一种选择是创建一个简单的宏。
That's always annoyed me too. One option is to create a simple macro.
如果执行上述步骤,Visual Studio将生成以下宏代码,您可以通过按 Alt-F8 来查看这些宏代码。并打开RecordingModule.TemporaryMacro:
If you follow the steps above, Visual Studio will have generated the following macro code, which you can see if you press Alt-F8 and open RecordingModule.TemporaryMacro:
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.NewLine()
您现在可以使用 Ctrl-Shift-P 运行此宏,但目前仅是一个临时宏。您应该保存它并将其分配给键盘快捷键。
You can now run this macro with Ctrl-Shift-P, but it's only a temporary macro at this point. You should save it and assign it to a keyboard shortcut.
所以现在,不要动手按 End ,然后按 Enter ,您只需按 Ctrl-Enter 。
So now, instead of moving your hand to press End and then Enter, you can just press Ctrl-Enter.
我也记录了另一个宏移到该行的末尾并为我键入 />,并将其附加到 Ctrl-/ 上。 VS生成的代码如下所示:
I also recorded another macro that moves to the end of the line and types " />" for me, and attached that to Ctrl-/. The code VS generates looks like this:
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = " />"
DTE.ActiveDocument.Selection.NewLine()
所有这些宏的替代方法是:关闭自动报价。打开工具菜单,然后转到选项,文本编辑器, XAML,其他。取消选中自动插入属性引号的选项。然后,它不会为您添加结尾引号,并且您不必使用箭头键或 End 键(尽管您必须键入结尾当然,现在报价)。
An alternative to all these macros is to turn off the automatic quotes. Open the Tools menu and go to Options, Text Editor, XAML, Miscellaneous. Uncheck the option for auto-inserting attribute quotes. Then it won't add the ending quote for you, and you won't have to use the arrow keys or the End key (although you will have to type the ending quote now, of course).