While I’ve picked out some specific commands, you can use this technique for any command that Visual Studio can produce, and create your own customized toolbars. Use the – button to collapse everything, and the + to toggle it back. Once done, close the Customize dialog, then you can drag your toolbar to an appropriate spot. I’m going to replace Outline Toggle All with + (a plus sign). Click in the Name area, and you can type over the name of the menu option. Right click on the Outline Toggle All command, and you’ll get a menu. OK, we now have our commands, but all that text looks pretty ugly. In this shot, you’ll see what it looks like when you’re done. Then, pick Outline Collapse to Definitions, and drag it into the toolbar. Now in the Commands list area, scroll down to Outline Toggle All, and drag it onto the toolbar. Click on the Commands tab of the Customize window. Now we need to drag our commands onto the toolbar. I’m now going to drag the new toolbar under the Customize window, just so it will look decent for the next screen capture. You’ll see your new toolbar pop up to the right of the Customize window. Give your toolbar a good name, it’s also helpful if you use something like your name to distinguish it from the rest of the built in bars. Right click in the toolbar, and select Customize. Now that we have the commands we want, let’s create a toolbar and hook them in. This makes Collapse All useless and my file is very hard to navigate. In my common scenario, I have some thing like Test with a lot of functions that are defined like test3. You’ll see a new command has shown up in Command Spy.Įdit.ToggleAllOutlining is what we are looking for here. When using Collapse All command (Ctrl M, O), test1, Test.test1 and Test.test2 are collapsed, but test2 and Test.test3 are not because they are arrow functions. Click on Edit, Outlining, Toggle All Outlining. Great, jot that down, and let’s run another command. (Note if you don’t see the Outlining option, make sure you’ve clicked in the code window.) Glancing down at the Command Spy window, you will see that the command issued was Edit.CollapseToDefinitions. There’s already a menu option to do this, click on Edit, Outlining, Collapse To Definitions. In this example, we’ll want to create a shortcut toolbar to collapse and expand all of our code regions with one click. You’ll see it’s window appear, just slide it to an out of the way space, or dock it. The rest of us will wait.īack now? Great. What? You haven’t installed it yet? OK, go read my blog posting from November 14 th ( ). First, we’ll need to fire up SlickEdit Gadgets Command Spy tool. In this first article, we’ll look at making a shortcut to a handy VS command. In case you hadn’t noticed, Visual Studio is just as extensible as the rest of the Microsoft tools. For years folks have been writing macros, add-ins for the office tools. The associated commands may be useful outside of an editing context, such as in auto generated code, code assistance extensions, etc.One of the great things about Microsoft is the way all of their stuff is extensible. While editing code I have a hard time thinking of time where one of these commands would be preferable to “Toggle Outline Expansion” above. These commands will collapse or expand the region under the cursor. This is relatively unintuitive.Įxpand Current Region and Collapse Current Region In the example below, if the Constructors region starts closed, typing this command will first open the region, and the command must be executed a second time to actually toggle all outlining. The first time you press Ctrl+ (M,L) if there is a mixture of open and closed sections in the file, the closed sections will be opened as the first step in the toggle. The word toggle suggests that repeating this command will switch outlining back and forth. All outlining is collapsed as much as possible.Ĭtrl+ (M,X) – this command works great for expanding everything so all code is visibleĬtrl+ (M,L) this command behaves someone strangely. In the example below this can be used to open and close the constructors region, as well as the Foo and Bar2 types separately.Ĭtrl+ (M, A) In the code below, this command does what you would expect. Pressing this command repeatedly will open and close the region or auto-outlined section under the cursor. Toggle Outline Expansion (Edit.ToggleOutlinineExpansion)Įxpand All Outlining (Edit.ExpandAllOutlining)Įxpand Current Region (Edit.ExpandCurrentRegion)Ĭollapse Current Region (Edit.CollapseCurrentRegion)Ĭtrl+ (M,M) – This is probably the shortcut that makes the most sense of this bunch. Toggle All Outlining (Edit.ToggleAllOutlining) Below I explain what each of these does in more detail.Ĭollapse All Outlining ( Edit.CollapseAllOutlining) How to fold and unfold all code sections in Visual Studio Code There are below shortcut commands to do it. These Shortcuts have been tested with Visual Studio 2017 15.87 with default settings. Visual Studio has several shortcuts available for expanding and collapsing sections of code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |