From the category archives:

MS Office

E=mc cubed

by Miraz Jordan on December 6, 2006

E=mc cubed
Mac Tip #272/06-Dec-2006

After the Tips about Find and Replace a reader asked how to find and replace the term m2, where the 2 is superscript (or raised up a bit and is a bit smaller, and it means ’squared’). What an interesting question!

If you use a program such as Microsoft Word, you type this kind of expression by simply typing m2, then selecting the 2 and choosing Format > Font > Superscript (or a shortcut such as Command Shift =, to achieve the same end result). If you need to type something like H2O for water you’d select the 2 and choose subscript, which lowers the character and makes it a bit smaller.

It’s easy to find and replace a superscripted (or subscripted) character: open the Find and Replace dialog box, enter the 2 in the Find what text box, enter the replacement (eg 3) in the Replace with box and then click the downward pointing arrow on the bottom line.

Click in the Find what text box, then click on the Format pop-up, click on Font… and check the Superscript (or Subscript) checkbox.

Now choose Replace All. Word replaces all superscripted 2s with superscripted 3s.

However, that wasn’t quite the question my reader had. My reader wanted a normal m together with a superscripted 2.

I did a fair bit of searching and came up empty, I’m afraid. It seems that the Find and Replace is all or nothing. For example, I italicised part of the word superscript. I could replace the entire word if it was in a regular style or the entire word in italics, but not a mixture of regular and italics.

By the way: if you’ve previously searched for formatted text, remember to click the No Formatting button next time you want to search for unformatted text.

Next week: End of year round-up.

Popularity: 12% [?]

{ No comments yet }

Count with Find and Replace

by Miraz Jordan on November 23, 2006

Count with Find and Replace
Mac Tip #270/22-Nov-2006

A reader reminded me that Find and Replace is a quick way to do some counting in your text. For example, perhaps you need to count how many times you’ve used a particular word — did you mention Product A as often as you mentioned Product B? Or perhaps you’d like to make sure you closed all the brackets you used.

Call up the Find and Replace dialog box for your software and enter your Search term, perhaps Apple, then put the same term in the Replace section. You’re replacing a word with the same word.

Now click Replace All. Most software gives you some kind of acknowledgement of how many replaces it made — perhaps as a simple count in the still open Find and Replace dialog box, or maybe in a separate alert, as you can see in the screenshots. [Click on the thumbnails to see larger versions.]

TextEdit shows how many replacements it made. . Tex-Edit Plus reports replacements in an alert.

Be careful though: watch out for words embedded in other words. If you need to count how often you’ve used the word ‘the’, then you should include a space after it, otherwise the program may also count anything where those letters appear consecutively such as in ‘there’, ‘either’ or ‘clothes’. Even the trailing space may not be sufficient, for some Blithe Spirits.

Next week: Replace in technicolour.

Popularity: 14% [?]

{ 1 comment }

Pattern Replace (3)

by Miraz Jordan on November 15, 2006

Pattern Replace (3)
Mac Tip #269/15-Nov-2006

Recent Tips have shown how to switch a pair of names using grep in Tex-Edit Plus and Microsoft Word. Please read those Tips again to refresh your memory of what’s going on. We used a regular expression to switch around names

This time we do a similar thing with TextWrangler, a free text editor from BareBones.

The reason for doing the same task in three different applications is to show that the fundamentals are the same, or similar, for each program, although details may vary. Moreover, different programs may offer slightly different grep features.

For example, TextWrangler has a ‘word boundary’ feature that we use this week to find ‘words’ rather than just ‘groups of letters’.

Download TextWrangler and paste in a list of reversed names:

  • Janeway, Kathryn
  • Summers, Buffy
  • Carter, Samantha
  • Torres, B’Elanna

Search

Press Command F to call up the Find and Replace dialog box and be sure to check the Use Grep checkbox.

The word boundary

TextWrangler allows us to look for a word boundary, and that’s just what we want: one word followed by a comma and space and then another word. The word boundary (\b) lets us construct a search to find any number of characters (.+) within the bounds of a word:

Search for: (\b.+\b), (\b.+\b)

Replace with: \2 \1

Click the Replace All button to switch the reversed names around to the first-last order we require. TextWrangler flashes up an alert to advise you that it has made the replacements.

This Regular Expression handles the apostrophe in a name without problems.

Next week: More Find and Replace tips

Popularity: 11% [?]

{ No comments yet }

Scenic New Zealand.