Toggling Line Numbers and Soft Wrap in TextWrangler
As with most text editors, TextWrangler provides many options that allow you to customize the editing interface. Two settings I sometimes change are accessible only as preference options or as toolbar menu items. As I would prefer to toggle these features with a single keystroke, I wrote a pair of scripts to do the job. Two associated keyboard shortcuts later, there’s no need to display the toolbar or visit the preferences.
Toggle Line Numbers
This script toggles the show line numbers
property of the frontmost text window.
Toggle Soft Wrap
This script toggles the soft wrap text
property of the frontmost text window.
Download
- Toggle Line Numbers 1.3 KB
- Toggle Soft Wrap 1.3 KB
The color scheme seen in the screenshots is Gruber Dark.
Installation
Unzip the scripts and put them in ~/Library/Application Support/TextWrangler/Scripts
. Keyboard shortcuts can be assigned with the Set Key
button in the Scripts
palette, found under Palettes
in the Window
menu.
Posted on Monday, April 28th, 2008. Tags: applescript, mac, textwrangler.
11 Responses to “Toggling Line Numbers and Soft Wrap in TextWrangler”
Posted by sergi bosch on Friday, November 6th, 2009 at 4:03 PM.
dude, glad u took the time to dev this. i’m going to give it a shot
right now. it appears to be EXACTLY what i’ve been looking for –
without realizing it’s what i needed. for example, i hate that i
have to always soft wrap when i open a doc; and secondly, i was
just searching for an alternative editor ’cause i couldn’t figure
out from their help how to use line numbers! solid.
Posted by sergi bosch on Friday, November 6th, 2009 at 4:11 PM.
do you happen to know why the TextWrangler script goes into
~/Library/Application Support/TextWrangler/Scripts —- rather than
into HD/Library/ApplicationSupport/ the question being, why does it
install itself at that particular directory? and would it be
possible to move it to the other? thanks
Posted by Jim on Saturday, November 7th, 2009 at 8:42 AM.
Hi Sergi,
Well, the scripts don’t install themselves – the Library folder in your home directory (~) is just a conventional suggestion. Things in the /Library folder are accessible/applied to all user accounts, which may or may not be appropriate.
Basically, when you run TextWrangler, it establishes an Application Support folder in your user account’s Library folder, but none in the shared /Library folder, which is why I suggest sticking with that convention.
If you’d rather use a different script runner besides TextWrangler’s built-in ability to run scripts, you could store the scripts anywhere, including ~/Library/Scripts or /Library/Scripts.
Posted by Fernando Hattori on Saturday, September 18th, 2010 at 1:36 PM.
Thank you for the Scripts. They are awsome. Exactly what I was looking for.
Posted by Jim on Saturday, September 18th, 2010 at 7:55 PM.
Thanks, Fernando! I’m glad you find them useful.
Posted by Lenore on Friday, February 18th, 2011 at 1:12 PM.
I just installed Textwranger on a new computer and now I can’t get softwrap of old files to set to anything but 80 characters. Any clues?
Posted by Jim on Wednesday, February 23rd, 2011 at 5:13 PM.
Hi, Lenore. The default soft wrap settings for new files are controlled in TextWrangler’s “Editor Defaults” preferences. You can choose whether to soft wrap to the page guide, the window width, or a character width of your choice (defaults to 80). For existing files, I think you want to to check “Text Options” under the Edit menu. Hope this helps. If not, I suggest contacting support@barebones.com
Posted by Bob C on Monday, December 12th, 2011 at 6:03 PM.
Looks like you wrote these quite a while back but i’m still thankful for them. Turning on soft wrap via the toolbar was very irritating. Thanks for making things a tad smoother.
Posted by Jim on Tuesday, December 13th, 2011 at 9:38 PM.
Glad you like it!
Posted by SnH on Friday, August 3rd, 2012 at 11:42 AM.
Thank you!! very useful.
I hate that hardwrap..messes everything..
Easy to edit!!
regards
Posted by Tao Wang on Wednesday, January 2nd, 2013 at 1:21 AM.
I tried, the soft wrap scripts does not work. I am wondering why.