[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [StrongED] Multiple changes to multiple files

>> I would like to apply changes to a set of 50 files
>> 1. Wrap a pair of <h1> tags around the first line of the file.
>> 2. Insert some lines of text before the first line of the file
>> 3. Wrap a pair of <h2> tags around all lines beginning with a #.
>> 4. Add some lines of text to the end of the file.

Gavin Wraith  wrote
> I am sure StrongED can do this with the right commands, but this
> sort of thing is very easy with StrongED scripting. Awk or Lua
> come to mind as the right tools for such a job. A RiscLua script
> could look like this:

> #! lua
> local wrapfmt = "<%s>%s</%s>"
> local wrap = \ (s, tag) => wrapfmt:format (tag, s, tag) end
> local line_no = 1
> print (start_stuff)
> for line in io.lines (arg[1]) do
>  if line_no == 1 then print (wrap (line, "h1"))
>  else
>   if line:sub(1,1) == "#" then print (wrap (line, "h2"))
>   else print (line) end -- if
>  end -- if
>  line_no = line_no + 1
> end -- for
> print (end_stuff)

> Fill in your own bits for start_stuff and end_stuff.

Thanks Gavin I will give it a try.

I can see how to do it with one file, but not how to do it with a set 
of files loaded into StrongED.



To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxxxxx