none
How to create Toggle Header / Code File toolbar button

    Question

  • I like using the Toggle Header / Code File option, but prefer not having to right click and pick the option in the code window.

    Pressing the Ctrl+K which is listed as a shortcut for the item toggles a bookmark on that line instead.

    Pressing Ctrl+O which is listed as the other shortcut for the item tries to opens the open file dialog instead, which is part of the file->open menu of course.

    So, can I create a toolbar button that'll do this? I'm used to using this feature in Visual Assist, but since this is built into Visual Studio 2015 Community, I was hoping to add a button to the toolbar that'll do this for me.

    Saturday, May 14, 2016 6:47 PM

Answers

  • Hi CriusMac,

    According to your description, you want to implement toggle files with shortcut in Visual Studio 2015, is it right?

    Since Ctrl+K and Ctrl+O have been assign to another function in Visual Studio by default. In Visual Studio, the default shortcut for toggle files is Ctrl+Tab, which will help us list all active code file in a pop up windows and then we can choose the file that we want to open through direction keys.

    And if you want to add some custom button in Toolbar, please try with following steps to add a custom Toolbar.

    1. Right-click in Toolbar to choose "Customize..." option.
    2. Click the "New..." button to add a new Toolbar for Visual Studio in the Toolbars tab.
    3. In the Commands tab, please choose the custom Toolbar in Toolbar section and then click the "Add Command..." button to add the function that you want.
    4. In your situation, you want to toggle code files. Please select "Window" in Categories list and choose "Previous Tab" and "Next Tab".
    5. Click "Ok" button and "Close" button.

    The custom Toolbar will list in Visual Studio Toolbar which is similar with following screenshot.

    If misunderstanding, please feel free to let me know.

    Best Regards,
    Weiwei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 16, 2016 9:05 AM
    Moderator

All replies

  • Hi CriusMac,

    According to your description, you want to implement toggle files with shortcut in Visual Studio 2015, is it right?

    Since Ctrl+K and Ctrl+O have been assign to another function in Visual Studio by default. In Visual Studio, the default shortcut for toggle files is Ctrl+Tab, which will help us list all active code file in a pop up windows and then we can choose the file that we want to open through direction keys.

    And if you want to add some custom button in Toolbar, please try with following steps to add a custom Toolbar.

    1. Right-click in Toolbar to choose "Customize..." option.
    2. Click the "New..." button to add a new Toolbar for Visual Studio in the Toolbars tab.
    3. In the Commands tab, please choose the custom Toolbar in Toolbar section and then click the "Add Command..." button to add the function that you want.
    4. In your situation, you want to toggle code files. Please select "Window" in Categories list and choose "Previous Tab" and "Next Tab".
    5. Click "Ok" button and "Close" button.

    The custom Toolbar will list in Visual Studio Toolbar which is similar with following screenshot.

    If misunderstanding, please feel free to let me know.

    Best Regards,
    Weiwei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 16, 2016 9:05 AM
    Moderator
  • @Weiwei: the functionality is present in the context menu ('Toggle Header / Code File) in Visual Studio 2017, but there is no menu command to bind a toolbar button.

    Monday, January 29, 2018 4:43 PM