TextWrangler Expert Preferences

There are a number of behaviors in TextWrangler for which there are no UI controls in the Preferences window; this is typically because the settings are so obscure that placing them in the Preferences window would just make it complicated. In fact, some of these settings were in the Preferences window, and have been removed in order to simplify the interface; in such cases, any changes you made previously will be honored, even though the UI in the Preferences window is gone.

Note: Adjusting the settings described here involves using the Unix command line (in the Terminal or a suitable replacement). Most changes will not have any immediate visible effect, but will instead take effect the next time you perform a relevant action, or, at the latest, after quitting and restarting TextWrangler.

Another note: Although they may wrap for display, each of the defaults write commands listed here is intended to be entered on a single line in the terminal. They will not work correctly otherwise.

Table of contents:


Editing

  • TextWrangler supports “camel case” navigation: press Control-left-arrow or Control-right-arrow to jump to the next (or previous) transition from lower-case to upper-case characters (or a word boundary, whichever comes first).

    Note that this use of Control-left-arrow and Control-right-arrow replaces the pre-8.5 behavior of using these key combinations to scroll horizontally. If you prefer the old behavior, you can do the following from the command line:

    defaults write com.barebones.textwrangler Editor_ControlArrowCamelCase -bool NO

    defaults write com.barebones.textwrangler Editor_ControlArrowHScroll -bool YES

  • When you backspace from the insertion point, TextWrangler will delete a tab stop’s worth of spaces if there are only spaces (and tabs) between the insertion point and the start of the line on which you’re editing. This may be disabled by an expert preference if desired:

    defaults write com.barebones.textwrangler Editor_DeleteIndentationWhitespaceToTabStop -bool NO

  • Automatic word counting is disabled for documents over a set size threshold, in order to avoid needless delays when working on very large documents. The factory default is 16M characters, but you may change this limit as desired using the following expert preference:

    defaults write com.barebones.textwrangler Editor_AutoWordCountSizeThreshold -int 16777216

    # Setting it to zero disables the limit check entirely.

  • Since “Find All Misspelled Words” is pretty much pointless on files over a certain size, the maximum amount of text checked by this command is limited to 1M (1024 squared) characters. This may be adjusted with an expert preference:

    defaults write com.barebones.textwrangler Editor_SpellCheckLengthLimit -int NN

    where “NN” is some decimal value. Use -int 0 to suppress the limit altogether.

  • By default, the “Balance” command (or double-clicking on a delimiter to balance) does not include the delimiters in the resulting selection. If you would like for it to do so:

    defaults write com.barebones.textwrangler BalanceIncludesDelimiters -bool YES

  • When using the Un/Comment command, if nothing is selected, TextWrangler will use the line comment delimiter to comment (or uncomment) the entire line. If you would prefer that TextWrangler insert the line-comment delimiter at the insertion point instead:

    defaults write com.barebones.textwrangler CommentWholeLineWithInsertionPoint -bool NO

  • By default, the “Shift Right” command on the Text menu will not add indentation to lines that are empty or consist entirely of white space. If you would prefer to indent every line, regardless of its whitespace-only nature, you can do so:

    defaults write com.barebones.textwrangler AllowShiftRightToIndentWhitespaceOnlyLines -bool YES


    Note that this preference can be set per-language in the usual fashion, by appending the language’s name to the preference key:


    defaults write com.barebones.textwrangler AllowShiftRightToIndentWhitespaceOnlyLines_C++ -bool YES

  • When you use the right-arrow key to navigate over a closing delimiter (right paren/brace/bracket/curly quote), the opening delimiter will be briefly highlighted. If you wish to turn this off, there’s an expert pref:

    defaults write com.barebones.textwrangler FlashBalancePointsWhenNavigating -bool NO


  • If you find that you frequently need to bring in text which contains combining Unicode characters (as are frequently found in PDFs generated on other platforms, for example), it can be desirable to preprocess the combining characters into one composed character where possible. This is not a general need, but if you run into it often enough, you can tell TextWrangler to combine the characters for you:

    defaults write com.barebones.textwrangler PrecomposeUnicodeWhenPasting -bool YES

    (Despite the name, the precomposition is done when TextWrangler imports the Clipboard from other applications, not when the paste is actually done.)

    Note that this requires an additional copy of the Clipboard when the application imports the text, and for very large pastes, there may be a noticeable delay while the text gets precomposed. Thus, you should only turn on this setting when you are frequently working with text that contains combining Unicode characters.

Back to top


FTP/SFTP

  • Settings are available for disabling passive FTP, in order to deal with hosts that misbehave when sent the PASV command.

    Passive FTP can be disabled per host, per domain, or globally:

    # only for “foobar.example.com”

    defaults write com.barebones.textwrangler DisablePassiveFTP:foobar.example.com -bool YES

    # only for servers in “example.com”

    defaults write com.barebones.textwrangler DisablePassiveFTP:example.com -bool YES

    # global preference

    defaults write com.barebones.textwrangler DisablePassiveFTP -bool YES

    Our recommendation is that you disable per host in preference to globally or per-domain.

  • Some servers don’t work correctly when SSH compression is enabled. To work around this, SSH compression can be disabled per host, per domain, or globally:

    # only for “foobar.example.com”

    defaults write com.barebones.textwrangler EnableSSHCompression:foobar.example.com -bool NO

    # only for servers in “example.com”

    defaults write com.barebones.textwrangler EnableSSHCompression:example.com -bool NO

    # global preference

    defaults write com.barebones.textwrangler EnableSSHCompression -bool NO

    Our recommendation is that you disable per host in preference to globally or per-domain.

  • Most of the time, the default timeout for connecting to an SFTP server will suffice; however, if the server is heavily loaded it may take longer to respond. To adjust the SFTP connection timeout:

    # set the timeout to 20 seconds — note that “-int” is required

    defaults write com.barebones.textwrangler SFTPConnectionTimeout -int 20

Back to top


File Comparison

  • When comparing text files, TextWrangler will canonicalize RCS keywords to their unexpanded state, so that the values of RCS keywords are not significant to the differences calculations. If you wish, you can disable this, so that any chance in the RCS keywords on a line will cause the line to appear in the differences:

    # Ignore variances in RCS keyword values when comparing

    defaults write com.barebones.textwrangler Diff_IgnoreRCSKeywords -bool NO

Back to top


Interacting with Other Applications

  • By default, TextWrangler will open AppleScript files using whatever application the OS claims is capable of doing so. If you wish to override this, change the “ScriptEditorBundleID” preference to the bundle ID of your preferred script editor. For example, to set the script editor to Script Debugger:

    defaults write com.barebones.textwrangler ScriptEditorBundleID com.latenightsw.ScriptDebugger

  • The “Run in Terminal” and “Go Here in Terminal” commands will use Apple’s “Terminal” application by default. If you would like to use a different one:

    defaults write com.barebones.textwrangler TerminalBundleID -string “com.example.TerminalAppBundleID”

    (Use the actual terminal’s bundle ID in place of “com.example.TerminalAppBundleID”…)

  • If Dash is installed, TextWrangler will use it for “Find in Documentation”, in preference to any predefined or custom reference lookup URLs. This can be controlled via an expert preference, on a per-language basis if desired:

    defaults write com.barebones.textwrangler UseDashForReferenceLookups -bool NO

    # turn off Dash support entirely

    defaults write com.barebones.textwrangler UseDashForReferenceLookups_Ruby -bool NO

    #turn off Dash support only for Ruby

    You could, if you wanted, turn off Dash support by default and then enable it for specific languages, e.g.:

    defaults write com.barebones.textwrangler UseDashForReferenceLookups -bool NO

    # turn off Dash support entirely

    defaults write com.barebones.textwrangler UseDashForReferenceLookups_C++ -bool YES

    #turn on Dash support only for C++

Back to top


Language Support

  • If you like, you can set the default language for new untitled documents:

    defaults write com.barebones.textwrangler DefaultLanguageNameForNewDocuments -string “<language name>”

    &lt;language name&gt;” should be the name of a language shown as installed in the Language preferences. For example, if you want your new documents to be Markdown:

    defaults write com.barebones.textwrangler DefaultLanguageNameForNewDocuments -string “Markdown”

  • Most of the factory supplied language modules generate fold ranges for any brace-delimited block that has at least one line, but to reduce noise, only block folds that have at least four lines are shown in editing windows. You can adjust this from the command line, using a language-specific preference key, which consists of “MinimumLinesForBlockFold_” (note the underscore) and the language name; for example:

    defaults write com.barebones.textwrangler MinimumLinesForBlockFold_Objective-C

    defaults write com.barebones.textwrangler MinimumLinesForBlockFold_Objective-C++ 4

    defaults write com.barebones.textwrangler MinimumLinesForBlockFold_JavaScript 4

  • Here are some language-specific settings for PHP. The settings with “Opaque” in their names refer to how certain structures are treated when scanning PHP code that’s embedded in HTML; when the preference is YES (the factory default in most cases), the corresponding structure is skipped so that any syntactic elements within it are ignored. When the preference is NO, the comment/string/etc delimiters are ignored and the structure’s contents are interpreted. (This is generally not desirable, but currently preserved for legacy compatibility.)

    defaults write com.barebones.textwrangler OpaqueStrings_PHP -bool NO

    defaults write com.barebones.textwrangler OpaqueBlockComments_PHP -bool NO

    defaults write com.barebones.textwrangler OpaqueLineComments_PHP -bool NO

    defaults write com.barebones.textwrangler OpaqueHereDoc_PHP -bool NO

    If you want variables to appear in the function menu in PHP documents:

    defaults write com.barebones.textwrangler ShowVariablesInFunctionList_PHP -bool YES

Back to top


Reading and Writing Files

  • TextWrangler ordinarily recognizes image files as images, and will open them into image windows (or ignore them when filtering for text files). To have images possibly treated as text files (which can be potentially dangerous):

    defaults write com.barebones.textwrangler QuickTimeImages -bool NO

  • By default, PDFs are considered text files and so may be opened and searched along with all other text files. To have PDFs treated as a special file type (they will be ignored for any operation that requires a text file):

    defaults write com.barebones.textwrangler OpenPDFsAsText -bool NO

  • To control whether TextWrangler warns you when opening a malformed UTF-8 file:

    defaults write com.barebones.textwrangler WarnMalformedUTF8 -bool YES

  • Ordinarily, TextWrangler will only ask you to choose a file’s encoding when it can’t otherwise figure out what the encoding is, and your “if the file’s encoding can’t be guessed” preference is a UTF-8 or UTF-16 variant. This should be fine for general use, but if for some reason you always want TextWrangler to ask you when it can’t guess a file’s encoding, even if your preference would do the job, you can:

    defaults write com.barebones.textwrangler AskForUnguessableFileEncoding -bool YES

  • Beginning with version 3.5, TextWrangler stores document state (window position and various settings) in a central repository in your TextWrangler preferences folder. If you wish, you can ask TextWrangler to store document state in the resource fork of the document’s file:

    defaults write com.barebones.textwrangler UseResourceForkForDocumentState -bool YES

  • By default, TextWrangler will not store document state for documents located in any of the canonical locations for temporary files. (This also includes the “svn-commit.tmp” files used for Subversion commits.) If desired, you can change this::

    defaults write com.barebones.textwrangler SaveDocumentStateForTempFiles -bool YES

  • By default, TextWrangler will avoid writing extended attributes (HFS Type/Creator) to volumes which don’t natively support them (i.e. to avoid creating the ._FILE) when it is safe to do so (i.e. we’ll be able to re-open the document correctly later.) If desired, you can fine-tune this behavior:

    defaults write com.barebones.textwrangler WriteExtendedAttributes <value>

    value” should be one of the following:

    • Always: Always write the HFS file type and creator (the pre-8.6 behavior)

    • Never: Never set the HFS file type and creator (even if the document’s volume supports it).

    • Smart: Write HFS file type and creator only if the document’s volume supports it

  • For text documents whose size exceeds a certain threshold (expressed in bytes, factory default 1MB), TextWrangler will ignore the Soft Wrap Text preference and leave wrapping off in order to improve the performance of opening very large files. The threshold may be adjusted if desired:

    defaults write com.barebones.textwrangler Editor_SoftWrapLengthThreshold -int 1048576

    If you set the limit to zero, TextWrangler will always honor the Soft Wrap Text preference, even in situations where soft-wrapping a large file may cause it to take a very long time to open.

  • The “Text Files Only” filtering in project lists and disk browsers looks inside of files if necessary, for improved filtering accuracy. This may be disabled, if desired:

    defaults write com.barebones.textwrangler InspectTextFileContentsForListFiltering -bool NO

  • TextWrangler makes a reasonable guess at a filename
    extension when using “Save As” for a new document. You can also set the preferred extension on a per-language basis:

    defaults write com.barebones.textwrangler PreferredFilenameExtension_<LanguageName> -string “abc”

    Replace &lt;LanguageName&gt; with the actual language name; for example:

    defaults write com.barebones.textwrangler PreferredFilenameExtension_C++ -string “cxx”

    defaults write com.barebones.textwrangler PreferredFilenameExtension_YAML -string “yaml”

    Note that the extension you specify should not include the leading period.

  • When examining a file to determine whether it is a Zip archive (for opening as well as when searching), TextWrangler will first examine the file’s UTI (Uniform Type Identifier) information; and if the UTI does not indicate that the file might be a Zip archive, filtering ends at that point. In some cases, this can lead to files being skipped that are in fact Zip archives, but which don’t have conforming UTIs. To solve this problem, you can disable UTI checking:

    defaults write com.barebones.textwrangler InspectUTIWhenFilteringZipFiles -bool NO

    Note: Disabling UTI inspection means that TextWrangler will always have to open the potential Zip file to inspect its contents. This will slow down batch operations such as multi-file search/replace, text factory application, and file filtering for projects and disk browsers when the directory being processed contains a lot of files that are potentially Zip archives (and not previously determined to be text files).

Back to top


Sleep and Auto-Save

  • Document auto-save (for crash recovery) is on by default, with a save interval of one minute. To change either setting:

    defaults write com.barebones.textwrangler EnableAutoSave_v2 -bool YES

    defaults write com.barebones.textwrangler AutoSaveIntervalInMinutes_v2 -int 10

  • The “Sleep” command does not save any documents in place, since it creates an auto-save file for any open documents with unsaved changes. However, if you want TextWrangler to save any titled (i.e. opened from an existing file) documents to disk before sleeping, you can do so as follows:

    defaults write com.barebones.textwrangler SaveTitledDocumentsBeforeSleeping -bool YES

  • TextWrangler provides control over whether documents on remote servers (FTP/SFTP) or unmounted volumes are opened when automatically reopening documents at application startup. You can modify its behavior with these settings:

    defaults write com.barebones.textwrangler AllowVolumeMountDuringStateRestore -bool YES

    # If set to YES, TextWrangler will not attempt to mount a volume

    # containing a document it wants to reopen. defaults to NO.

    defaults write com.barebones.textwrangler ReopenRemoteDocuments -bool YES

    # If set to NO, TextWrangler will not attempt to open any documents

    # that were opened from FTP/SFTP servers. Defaults to YES.

    defaults write com.barebones.textwrangler PromptToReopenRemoteDocuments – bool YES

    # If set to YES (the default), TextWrangler will prompt to give you the

    # opportunity to skip remote documents.

    # If set to NO, TextWrangler will open remote documents without

    # asking, if ReopenRemoteDocuments is set to YES.

    # Has no effect if ReopenRemoteDocuments is set to NO.


Text Display and Coloring

  • Whether or not TextWrangler uses font smoothing (anti-aliasing) may be adjusted separately for fixed-width and for proportional fonts:

    defaults write com.barebones.textwrangler FixedWidthFontSmoothingThreshold -int 10

    defaults write com.barebones.textwrangler FontSmoothingThreshold -int 4

    The factory default smoothing thresholds are 10pt for fixed width fonts, and 4pt for proportional fonts, respectively. Font sizes above the specified threshold are smoothed; font sizes below the threshold are not.


  • If you want to unconditionally disable text smoothing for a specific font, you can do so as follows:


    defaults write com.barebones.textwrangler DisableFontSmoothing_FONTNAME -bool YES


    “FONTNAME” is the display name of the font, as it appears in the Fonts panel or the Font Book application. For example, this will disable font smoothing for Monaco:


    defaults write com.barebones.textwrangler DisableFontSmoothing_Monaco -bool YES

Back to top


Text Search and Replace

  • Like many Mac OS X applications, TextWrangler supports the “Find Scrap”, a feature of the OS that enables sharing of the “search for” string between applications. Some applications put inappropriate content (such as Web search strings) on the Find Scrap, which can cause the “search for” string in TextWrangler’s Find dialog to be replaced when you didn’t expect it.

    To tell TextWrangler not to import the Find Scrap into its Find window, nor to export the “search for” string to the Find Scrap:

    defaults write com.barebones.textwrangler FindDialog_UsesFindScrap -bool NO

  • Ordinarily, TextWrangler will color the search and replace patterns in the Find window. To disable coloring of these patterns:

    defaults write com.barebones.textwrangler FindDialog_ColorGrepSyntax -bool NO

  • The Live Search bar is not visible by default, but appears when you choose “Live Search” from the Search menu. If you would like the Live Search bar to be visible in each new document that you create or open:

    defaults write com.barebones.textwrangler Editor_AlwaysOpenQuickFind -bool YES

  • When performing a single-file “Replace All” operation, TextWrangler will show a confirmation sheet showing the number of replacements performed. If you would prefer not to see this confirmation, you can suppress it:

    defaults write com.barebones.textwrangler ReportReplaceAllResults -bool NO

  • If you want to amaze and impress your friends and family with just how fast TextWrangler’s Replace All is, there’s an expert preference for that:

    defaults write com.barebones.textwrangler ReplaceAllResultsIncludeTiming -bool YES

    When turned on, the sheet (or growl notification) will display the amount of time required for the Replace All operation.

Back to top


Windows and UI Tweaking

  • When using the “Previous Document” and “Next Document” commands on the View menu, or the navigation arrows in the navigation bar, the order in which TextWrangler navigates documents is determined by the order in which they were opened. If you prefer, these commands can be made to navigate the documents in the order shown in the file list.

    defaults write com.barebones.textwrangler SurfNextPreviousInDisplayOrder -bool YES

  • TextWrangler attempts to move windows as little as possible when you zoom them. To override this and let TextWrangler place the window in the upper left-hand corner of the screen:

    defaults write com.barebones.textwrangler ZoomWindowsInPlace -bool NO

  • When entering full screen mode, the application figures out whether the window width should be increased to take up the full screen width, or not, based on the width of the window relative to the width of the screen that it’s on. The threshold at which the window is made to take up the entire screen width can be set thus:

    defaults write com.barebones.textwrangler FullScreenWidthThreshold -float 0.65

    The threshold is a percentage, so (in the example above), if the window is 65% or more of the width of the screen that it’s on, it will take up the full width of the screen when entering full screen mode.

    Note that when setting the threshold, you must set it as a decimal number, using “-float &lt;some number between 0 and 1&gt;”.

    At any time, you can override the threshold and cause the window to use the entire width of the screen, by holding down the Command key as you click on the full screen control

  • The “Remember the … most recently used items” setting in the Application preferences applies to all item types. So, if it’s set to 15, TextWrangler will remember 15 text documents, 15 folders, 15 images, and so on. If you want finer control, you can construct an expert pref using the name of the document type as it appears in the menu (and if that name contains spaces, you’ll need to quote it). So, for example, if you only wanted to remember the ten most recent folders:

    # remember only the ten most recent folders

    defaults write com.barebones.textwrangler NSRecentDocumentsLimit:Folders -int 10

    Or only the most recent shell worksheet:

    # remember only the most recent worksheet

    defaults write com.barebones.textwrangler “NSRecentDocumentsLimit:Shell Worksheets” -int 1

    If you don’t want to remember any recent documents of a particular type (they won’t appear in the menu, either), you can set its limit to zero:

    # don’t remember any images

    defaults write com.barebones.textwrangler NSRecentDocumentsLimit:Images -int 0

    You can also control the number of items shown in the “Most Recently Used” group:

    # Show up to 15 items in the “Most Recently Used” group:

    defaults write com.barebones.textwrangler MostRecentItemsGroupLimit -int 15

    Note that when setting any recent items limit, you must set it as an integer, using “-int &lt;some number&gt;”.

    By default, TextWrangler does not remember recent items opened from any of the canonical locations for temporary files. (This also includes the “svn-commit.tmp” files used for Subversion commits.) If desired, you can change this:

    defaults write com.barebones.textwrangler RecentItems_RememberTempFiles -bool YES

  • Ordinarily, the application will use the current editing view’s font (at reduced size) for the numbers in the Line Numbers bar. If you would instead prefer to use the miniature system font at fixed size:

    defaults write com.barebones.textwrangler UseEditorFontForLineBar -bool NO

Back to top


Miscellaneous

  • When searching for matches, Open File by Name limits the number of matches to a reasonable maximum. The factory default is 200, and may be adjusted:

    defaults write com.barebones.textwrangler OpenByNameMaxWildcardMatches -int 200

  • Ordinarily, the output from Unix scripts run within TextWrangler is delimited with line separators (except when the script output is sent to a new untitled document). If you wish to suppress the separators, you can do so:

    defaults write com.barebones.textwrangler UseSeparatorsInUnixScriptOutput -bool NO

Back to top