Auto-convert tab to 4 spaces in TextWrangler?
Asked Answered
A

7

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

Aerification answered 21/4, 2011 at 22:16 Comment(0)
A
97

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

Aerification answered 21/4, 2011 at 22:32 Comment(8)
restart TextWrangler on mac before it takes effect for already open documentsChiefly
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.Unanswerable
Didn't apply on already open documents, even after restart, but does work for new documentsChildbearing
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)Twittery
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.Stacte
working for me on open documents, created before or after, etc., after a restart. Tested on January 2015, v.4.5.12Inharmonious
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).Spelling
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.Tiaratibbetts
K
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.

Koala answered 25/6, 2011 at 3:36 Comment(2)
If the option is disabled like it was for me, just highlight the entire document and indent then outdent back.Crackerbarrel
In the newer versions of TextWrangler the button looks like a toothed wheel.Tali
P
9

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

Precocity answered 21/1, 2014 at 13:34 Comment(1)
Works nicely on existing document if you want to change existing tabs to spaces in one go.Selfdiscipline
O
7

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!

Onondaga answered 27/10, 2015 at 21:17 Comment(1)
The Detab option was exactly what I was looking for, thank youEndlong
W
4

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

gear button

Wainwright answered 29/3, 2017 at 21:32 Comment(0)
H
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.

Hazelton answered 20/6, 2013 at 17:29 Comment(0)
T
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
Tiffaneytiffani answered 24/12, 2020 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.