67

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

Greg Glockner
  • 4,881
  • 2
  • 17
  • 21
Kevin Burke
  • 49,451
  • 66
  • 163
  • 280

7 Answers7

96

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

Kevin Burke
  • 49,451
  • 66
  • 163
  • 280
  • 18
    restart TextWrangler on mac before it takes effect for already open documents – pulkitsinghal Jun 08 '12 at 20:55
  • 24
    simply, did not work for me, even after restart, v is 4.0.1 (3152). found same setting under |Edit -> "Text Options..."| that worked though. – mert inan Jul 16 '13 at 13:00
  • Didn't apply on already open documents, even after restart, but does work for new documents – smoens Nov 05 '13 at 13:47
  • 5
    Not only doesn't it work for open documents, but it doesn't work for any documents created before you change that setting. If after restarting, you open a document that created before the change, the old setting still applied. But any document created after the change is fine. (version 4.5.2) – chepukha Nov 12 '13 at 22:35
  • Not working for me. Seems like tabs are not converted to spaces. Because when I hold a left-right arrow key, it doesn't jump. But when I copy the text to another window, the tabs are still there. – wannik Mar 19 '14 at 07:55
  • working for me on open documents, created before or after, etc., after a restart. Tested on January 2015, v.4.5.12 – PatrickT Jan 04 '15 at 18:02
  • 5.0.2, OS X. Still doesn't work for me, even after restarting. Workaround: for the file that is "stubborn" and won't reflect your newly-chosen preferences: close it inside the app. Then, from the Finder, drag'n'drop it on the app. It will open it as a new, "untitled" document. Save this one over the offending file, effectively overwriting it. From now onwards, said file will act like the others (that were modified after changing the preferences). – elder elder Jan 28 '16 at 16:43
  • 2
    Since that seems to be a pain point: BBEdit and TextWrangler have *per-document* preferences. Once the global setting has been changed, you still need to change it in documents that have been opened before, since global settings only apply when you open a file that has never been opened before. – zneak Apr 12 '17 at 16:59
62

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.

Adrian Mole
  • 30,672
  • 69
  • 32
  • 52
queso
  • 1,110
  • 8
  • 6
9

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

robm
  • 1,133
  • 1
  • 12
  • 22
  • Works nicely on existing document if you want to change existing tabs to spaces in one go. – Mahdi Apr 23 '15 at 12:44
6

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!

Lukasz Czerwinski
  • 9,482
  • 8
  • 45
  • 56
4

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

gear button

green0range
  • 387
  • 4
  • 16
2

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.

Lore
  • 21
  • 1
0

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
timeSmith
  • 469
  • 1
  • 7
  • 13