I am a bit lazy when it comes to formatting code in Visual Studio and almost rely solely on the magic of Ctrl + K , Ctrl + D (or F depending on what I'm doing). However I loathe having to use my right mouse button to Remove and Sort my using statements and am constantly forgetting.
Assuming that I'm not using Re-Sharper is there any way to extend the Ctrl + K , Ctrl + D keyboard shortcut to format my code and sort my using statements?
Would writing a macro to do both tasks and assigning it the same key combination the only way to do it?
It's not extending the current key combo as such, but there's a Edit.RemoveAndSort command to which you can assign a key binding in Tools -> Options -> Keyboard.
Here's a blog post detailing just that.
From the lack of response I can only assume that I'll need to create a macro and assign it the same keyboard shortcuts... oh well
Sub LazyFormatAndSortUsingMacro()
DTE.ExecuteCommand("Edit.FormatDocument")
DTE.ExecuteCommand("Edit.RemoveAndSort")
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.