Applying Space Formatting in Visual Studio

In vim, if you, say, copy a block of code into a file and it gets all awkward, you can press == or = G to apply space formatting to the line (or to the end of the file). Is there a way to get this functionality in Visual Studio 2008? I found this stone:

Ctrl-K, Ctrl-F Applies indentation and space formatting for the language, as specified in the Formatting panel, in the Text Editor section of the Options dialog box, to the selected text.

I'm not sure what this means and when I tested it I didn't get anything.

+2


source to share


4 answers


Try CTRL+ K, CTRL+D

You can define the current mapping by going to Tools β†’ Options β†’ Environment β†’ Keyboard β†’ enter "Document Format" and select an option Edit.FormatDocument

. Check the Shortcuts for Selected Command drop-down list.

For example, in Visual Studio Team System 2008 Development Edition with environment setup for C # I see 3 assignments:

  • CTRL+ K, CTRL+D
  • CTRL+ E, CTRL+D
  • CTRL+ E,D


Alternatively from the menu: Edit β†’ Advanced β†’ Document Format.

Depending on the development options you originally selected when you first started Visual Studio, this menu will change. Based on my observations, the above applies to General, C #, VB and Project Management.

If you chose web development, the option will be Edit β†’ Format Document.

To reset your environment settings: Tools -> Import and Export Options ... -> reset all settings -> Save current settings (optional) -> Select a default preset from the list provided.

+5


source


I think it should be, select "All" and then ctrl+ K+ D.



+1


source


For me, the Alt+ F8works (reformatting the selection), but I have "C-Key bindings" that are not standard.

+1


source


I had the same problem. I have excluded the asp page from the project. After including it in the project, the formatting worked. Hope this helps.

+1


source







All Articles