Inserting Text before and after a multi-line selection

428 views
Skip to first unread message

Necrominog

unread,
Apr 20, 2009, 2:35:45 PM4/20/09
to TextWrangler Talk
Hi, I'm trying to insert text before and after a selection of multiple
lines. I can get text to insert before and after a selection if it is
all in the same line (prefix and suffix) but when I try to do the same
on several lines each line in the selection gains the prefix and
suffix. I only want the prefix and suffix to appear once regardless of
how many lines are in the selection. If anyone has any ideas or could
point me in the right direction I would appreciate it.

Thanks,
'nog

Tom Robinson

unread,
Apr 20, 2009, 8:05:23 PM4/20/09
to textwr...@googlegroups.com

Maybe an AppleScript to replace the current selection with A+Selection
+B ?

(You can call AppleScripts from within TextWrangler by using
TextWrangler's Scripts menu or the system-wide scripting menu.)

Patrick Woolsey

unread,
Apr 21, 2009, 9:05:16 AM4/21/09
to textwr...@googlegroups.com
Necrominog <necro...@att.net> sez:

The purpose of the Prefix/Suffix Lines command is to apply (or remove) a
prefix and/or suffix to every line in the selection.

If your selections are arbitrary, i.e. you need to manually choose the
start and end points, and you don't need to process too many such items, it
may be easiest to just locate those points and type the desired text. :-)

Alternatively, if this is something you need to do often, an AppleScript as
Tom suggested may be the way to go.

If there's a pattern to the content you want to modify, e.g. all paragraphs
which start with "boat", then you can likely perform a grep search &
replace to select each section and add the desired info before and after.


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com>
P.O. Box 1048, Bedford, MA 01730-1048

Necrominog

unread,
Apr 23, 2009, 1:02:35 PM4/23/09
to TextWrangler Talk
Thanks Patrick and Tom. I guess one thing that I neglected to mention
was that I was working in applescript already (newbie). I did
eventually figure it out, just had to sleep on it.

If you are feeling brave I've posted another question for you :-)

Thanks again!

'nog

On Apr 21, 6:05 am, Patrick Woolsey <pwool...@barebones.com> wrote:
Reply all
Reply to author
Forward
0 new messages