There are four commands that involve converting spaces to tabs and tabs to spaces.

Edit – Advanced – Tabify Selected Lines – Replaces the leading whitespace on a line that contains the selection with tabs. 

Edit – Advanced – Untabify Selected Lines  – replaces the leading whitespace on a line that contains the selection with spaces. 

Tabify and Untabify Selected Lines menu items

Note: The Edit – Advanced – (Un)Tabify Selected Lines isn’t supported for VB. 

Edit.ConvertTabsToSpaces – converts selected whitespace to spaces. 

Edit.ConvertSpacesToTabs – converts selected whitespace to tabs. 

Convert Spaces To Tabs shown in Tools Options Keyboard page

Note:

  • Theses commands are not available by default on the Edit menu, so you’ll either have to bind it to a keyboard shortcut, put it on the menu yourself (tip coming soon), or run it from the Ctrl+D Window (tip coming soon).
  • You may have to uncheck Tools – Options – Text Editor – Basic – VB Specific – Pretty Listing (reformatting) of code to use Edit.ConvertTabsToSpaces and Edit.ConvertSpacesToTabs – provided you’re using tabs as the default and want to convert something to spaces.  But the other way will work fine (if default is tabs and you’re converting spaces to tabs)

Technorati tags: VS2005Tip, VS2008Tip