Tuesday, April 30, 2013

Tip 2.9: How to convert spaces to tabs and tabs to spaces

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



There are four commands that involve converting spaces to tabs and tabs to spaces. The first two commands are found on the Edit–Advanced menu:
  • Tabify Selected Lines Replaces the leading white space on a line that contains the selection with tabs.
  • Untabify Selected Lines Replaces the leading white space on a line that contains the selection with spaces.




Note

The Edit–Advanced–(Un)Tabify Selected Lines isn't supported for Microsoft Visual Basic.
The last two commands are not found on the Edit menu but are available for you to either bind to a keyboard shortcut or manually add to the Edit menu or Text Editor toolbar:
  • Edit.ConvertTabsToSpaces Converts selected white space to spaces.
  • Edit.ConvertSpacesToTabs Converts selected white space to tabs.




Note that you may have to uncheck Tools–Options–Text Editor–Basic–VB Specific–Pretty Listing (Reformatting) of Code to use Edit.ConvertTabsToSpaces and Edit.ConvertSpacesToTabs.

Happy Programming! =)
Posted by Nils-Holger at 11:48 AM with 1655 comments.

Monday, April 29, 2013

Tip 2.8: How to keep tabs or to insert spaces

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



Sara Aside

This tip and Tip 2.9 were her least favorite features to test. It drove her crazy trying to keep track of when a tab should get inserted, when the cursor should move to the correct formatted position, and so on and so forth. Now she uses only spaces in her code. =)
Go to Tools–Options–Text Editor––Tabs to switch between using tabs and inserting spaces.



Note that you can set this for all languages on the Text Editor–All Languages page, but usually this is something you want to set for each individual language.

Happy Programming! =)
Posted by Nils-Holger at 1:14 PM with 533 comments.

Sunday, April 28, 2013

Tip 2.7: How to format the document, the selected text, or just the current line

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



Ever been typing in the editor and, for whatever reason, the text isn't indented properly on the line? Instead of manually pressing Backspace or Tab for each line of text, just press Ctrl+K, Ctrl+D, which performs the Format Document command. For larger files, you might just want to select the region that isn't justified correctly and use Ctrl+K, Ctrl+F. This keyboard shortcut formats the current line if you have nothing selected. These commands are found under the Edit–Advanced menu.



Happy Programming! =)
Posted by Nils-Holger at 12:53 PM with 509 comments.