Page 1 of 1

Header and Footer

Posted: Mon Dec 17, 2007 8:05 pm
by ravilobo
I have around 40 files, in which header and footer (constant string) is required. How to achieve this using regular expressions or macro?

Posted: Tue Dec 18, 2007 3:30 pm
by talleyrand
Macro route, assuming you have no objection to repeating it 40 times.

Macros -> Record (Ctrl-Shift-R)
Ctrl-Home (resets cursor position to first line, first column)
{Insert your header material}
Ctrl+End (resets cursor position to end line, last column)
{Insert your footer material}

Macros -> Stop Record (Ctrl-Shift-R)

Save that macro out and any new documents or any existing documents can have that macro run against them. Might want to explicitly add in a carriage return (enter) before adding your header/footer.

WildEdit might have the ability to do this even easier with a regex that says "match entire document" and replace with "header"\1"footer"

Posted: Tue Dec 18, 2007 7:57 pm
by Bob Hansen
Can also put the header and footer into a library clip that surrounds the selected text. So, Select All, Select "Header/Footer" from Clip Library.

Posted: Tue Dec 18, 2007 10:17 pm
by ravilobo
Thanks Bob. Thanks talleyrand.

As talleyrand mentioned I was looking for an option similar to - "match entire document" and replace with "header"\1"footer"

Posted: Wed Dec 19, 2007 1:06 am
by Bob Hansen
Both the macro and clipboard accomplish the same thing, but without using RegEx.

Posted: Sun Jun 29, 2008 10:54 pm
by Jam
I needed to do the same thing, but I didn't want to use macro or clip library since I had to do it with 3000 files... here is the regex solution in case anyone else is in the same situation :

\A = start of file

\z = end of file

Works perfectly!

Posted: Sun Jun 29, 2008 11:00 pm
by talleyrand
:?
Admitedly, I don't have WildEdit installed on this virtual, but those two regular expression escapes don't appear to work with TextPad.

Posted: Sun Jun 29, 2008 11:07 pm
by Jam
You're right, sorry I forgot to mention that these worked with WildEdit.

I don't know if it's possible with TextPad regex, but anyway I don't think TextPad could handle 3000 files open at once, certainly not on my computer - it seems to break somewhere around 500.