Hi Adam,

Building on Rich's answer, you could use the Canonize functionality here. 

(Quoted from the User Manual)
Canonize
This command allows you to perform batch search and replace operations 
which are governed by a pre-defined file. The transformation file is itself 
a list of paired search and replace strings or grep patterns, one pair per 
line. Each search string (or pattern) is separated from its replace string 
(or pattern) by a literal tab, so if you want your searches or replacements 
to match or insert tabs, you must use the special character “\t” within the 
corresponding strings.

1. Create a foobar.txt file with the following content (with tab 
separators):

# -*- x-bbedit-canon-grep: 1; -*-
\A  foo\n
\Z  \nbar
 
2. Use menu Text > Canonize... on your front document using the foobar.txt 
file.

\A is a regular expression for beginning of document.
\Z is a regular expression for end of document.
Applying Canonize with the foobar.txt file adds "foo" on a new line at the 
beginning of the document
and a new line with "bar" at the end of the document.

You should be able to create a text factory on this bases.

HTH

Jean Jourdain
On Monday, September 20, 2021 at 9:26:24 PM UTC+2 [email protected] 
wrote:

> On 20 Sep 2021, at 14:16, Adam Potthast wrote:
>
> > I'm looking for a textfactory action like "Prefix/Suffix Lines", but I 
> > want
> > to automatically add a string to the beginning and end of each file 
> > (not
> > each line). I figured finding this would be easy, but so far it has 
> > escaped
> > me.
>
> Using Grep, "\A" matches the beginning of the file; and "\z" matches the 
> end of the file.
>
> So, you could do two searches:
>
> \A replace with foo\n
>
> and
>
> \z replace with bar\n
>
> which I think will do what you need.
>
> R.
>
> -- 
> Rich Siegel Bare Bones Software, Inc.
> <[email protected]> <https://www.barebones.com/>
>
> Someday I'll look back on all this and laugh... until they sedate me.
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/01af2a11-cf4c-4350-b860-e66820a4d65cn%40googlegroups.com.

Reply via email to