Auto-convert tab to 4 spaces in TextWrangler?


Tabs Problem Overview

Is there a preference in Textwrangler to redefine a tab as 4 spaces? In Vim this is set expandtab in the vimrc, but I don't know how to set it in TW besides clicking "Detab" when I'm done editing the document.

Thanks, Kevin

Tabs Solutions

Solution 1 - Tabs

Go to "Preferences" -> "Editor Defaults" -> "Auto-expand tabs," and then set tabs to 4 spaces. Then restart TextWrangler for changes to take place.

Solution 2 - Tabs

For docs that already exist you have to hit the "Text Options" button in the top of the editor window of the open document. In older versions, it's the button that looks like a "T" with a light switch next to it; with newer versions, it's a gear "⚙" icon. In that drop down there is the "auto-expand tabs" as well.

Solution 3 - Tabs

in version 4.5.5, there is 'Text -> Detab...', which pops up a requester for how many space per tab, preset for 4.

Solution 4 - Tabs

Go to Edit -> Text Options and tick Auto-expand tabs. This will make all the new tabs to change to spaces.

To change all current tabs to spaces as well, go to Text -> Detab and hit Detab.

Hope that helps!

Solution 5 - Tabs

For Mac, another easy way to check and enable "Auto-expand tabs" is to hit the gear button on top left.

gear button

Solution 6 - Tabs

You can also use "Normalize Options..." to set the text options of an already-open document to whatever you have set in your Preferences. This is useful for dealing with pre-existing code.

Solution 7 - Tabs

There are two places you need to set the settings for this to work. One is for previously opened documents, and the other for all documents to be opened or created in the future.

The Settings

  • set "Auto-expand tabs" to checked
  • set "Tab width" to 4

Previously Opened Documents

  • Click the "Text Options" button. It is in the top left of the editor window directly above the document view of the open document. In newer versions it's a gear "⚙" icon. And in older versions it is a "T" and light switch.

New Documents

  • go to preferences menu: BBEdit -> Preferences
  • choose "Editor Defaults" from the side-bar in Preferences


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKevin BurkeView Question on Stackoverflow
Solution 1 - TabsKevin BurkeView Answer on Stackoverflow
Solution 2 - TabsquesoView Answer on Stackoverflow
Solution 3 - TabsrobmView Answer on Stackoverflow
Solution 4 - TabsLukasz CzerwinskiView Answer on Stackoverflow
Solution 5 - Tabsgreen0rangeView Answer on Stackoverflow
Solution 6 - TabsLoreView Answer on Stackoverflow
Solution 7 - TabstimeSmithView Answer on Stackoverflow