Count words in TextWrangler

I tend to write my texts, at least for blogging, in a text editor and then cut & paste them into where ever. The editor I tend to use nowadays is TextWrangler from Bare Bones Software. Why? Well, I find that a text editor lets me focus on the task at hand much better than a word processor, and TextWrangler happens to be free. It is the conceptual child of BBEdit Lite which I used to use under System 7 and OS 9. Other excellent apps would be BBEdit, TextMate or Tex-Edit. Tex-Edit is an old favourite I just discovered exists in an OS X version! And it is extremely AppleScriptable and has great Automator support as well. Switch coming on?

The problem is though that most text editors do not have a word count feature.* This is not a problem for coders, but for us knowledge workers it can be of utmost importance. Enter the glory of AppleScript!

Over at Nabble I found the base of this script, and added the display function my self. It is simple, it is not the second coming, but it is highly useful to a particular sort of person. Feel free to use it as you wish.

tell application "TextWrangler"
count words of selection
display dialog "Number of words in document: " & result giving up after 1
end tell

I would like to ask that if you add to this script, especially Growl support or live updating, please notify me.

TextWrangler – It doesn’t suck… either!

Thobias

Edit: For those who do not know how to use this code, I recommend that you read this newbie guide.
* Update: However, Bare Bones TextWrangler does have a word count function, and I failed to mentioned this. Why? Well, call it a slip of the keyes… I missed it, I can’t say anything but: I am sorry, and I apologise if I misled anyone with this.

** UPDATE 2: It’s been pointed out that I don’t tell you HOW to count words in TextWrangler, except with this AppleScript above. Here is how to do it, courtesy of amateur6.

“For the record: go to View -> Get info (or simply press Command-i from within the document). You’ll get Character, Word, Line and Page counts.

Or if you want to be fancy, do a Grep search using “([^\W\r\n]*)\w|([^\W\r]+)\r|([^\W\n]+)\n ” without the quotes (although this generated one false positive for me, so I’d just go with Get info).”

Advertisements

16 responses to this post.

  1. Hi webmaster!

    Reply

  2. Hi webmaster!

    Reply

  3. Do you tweet and have a twitter account so I can follow you?

    Reply

  4. Posted by amateur6 on January 26, 2010 at 9:27 pm

    I realize this is an old post, but since this page is the NUMBER ONE Google response for “TextWrangler word count”, and the summary begins “Update: However, Bare Bones TextWrangler does have a word count function, and I failed to mentioned this. Why? Well, call it a slip of the keyes [sic — another slip of the keys 🙂 ]…” — wouldn’t it be nice if you told us what it IS?

    For the record: go to View -> Get info (or simply press Command-i from within the document). You’ll get Character, Word, Line and Page counts.

    Or if you want to be fancy, do a Grep search using “([^\W\r\n]*)\w|([^\W\r]+)\r|([^\W\n]+)\n ” without the quotes (although this generated one false positive for me, so I’d just go with Get info).

    Reply

  5. @amateur6 You are right, my bad. I just thought everyone but me knew! I’ll add this to the post.

    Reply

  6. Fantastic. Great info gem. The only other thing TextWrangler needs IMO is a way to append file the file when you save a document. The number of times I’ve neglected to write in .txt as part of the file name and then have email recipients ask me how to open the file… kinda defeats the purpose of using .txt in the first place.

    Reply

  7. wordpress is the best blogging platform ever’~;

    Reply

  8. WordPress is definitely the best blogging platform, no one can beat wordpress.“

    Reply

  9. Thanks for the publish up. I believe the things pointed out within your theme is in fact spot on. I have been undertaking preliminary exploration relating towards the subject and your piece has cleared up several uncertainties I had. I’m working on an dissertation aw properly like a term piece for my English subject and am already shopping as a result of a lot of net blogs to study. Also, loving the blog site layout. I had a identical web site to yours just before I sold it on.

    Reply

  10. I am in truth not too good with this topic but I do like to see websites for design themes and fascinating topics. You actually thrived upon a matter that I normally don’t care lots about and made it really entertaining. This is a fine blog that I will take notice of. I already earmarked it for potential credit. Ta

    Reply

  11. *~’ I am really thankful to this topic because it really gives useful information :’`

    Reply

  12. Nice weblog here! Additionally your website lots up self-same fast!

    What web congregation are you the usage of? Can I get your affiliate
    relationship to your host? I want my web position rolling in it cheery as quickly as yours lol

    Reply

  13. I’m really loving the theme/design of your site. Do you ever run into any browser
    compatibility issues? A handful of my blog readers have complained about my blog not operating correctly in Explorer but looks great in Chrome.
    Do you have any tips to help fix this problem?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: