Discussion:
How to add text on multiple lines (without using the Replace menu).
eric.bouyoux
2011-02-17 08:45:38 UTC
Permalink
Hi,

Somebody I work with is using nedit. His preferred text editor is
Ultraedit but we don’t have it installed at work.
He would like to do the following (I explained him how to do it with
regular expression and the Replace menu, but it can be interesting anyway)
:

He needs to replace :

Line1
Line2
Line3

Into :

<added text>Line1
<added text>Line2
<added text>Line3

Doing it this way :

Select all first characters of each line by column (with Ctrl + Left
mouse)
Then enter the text to add once. This text is automatically inserted in
real time on all lines.

Is there a way to do that THIS WAY with Nedit ?

Regards.

Eric Bouyoux.
--
NEdit Discuss mailing list - Discuss@
Aaron W. Hsu
2011-02-17 09:12:27 UTC
Permalink
Post by eric.bouyoux
Select all first characters of each line by column (with Ctrl + Left
mouse)
Then enter the text to add once. This text is automatically inserted in
real time on all lines.
I do not think that you can get this with the live update, but you can
bind a macro to do "Prefixing" operations, and there you can have the
macro raise a dialog to prompt for the text once. That hides away any
search and replace things.

You can also use a UNIX filter. I have also done a keyboard recording for
this sort of thing.

Aaron W. Hsu
--
Programming is just another word for the lost art of thinking.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
eric.bouyoux
2011-02-17 15:43:37 UTC
Permalink
Post by Aaron W. Hsu
Post by eric.bouyoux
Select all first characters of each line by column (with Ctrl + Left
mouse)
Then enter the text to add once. This text is automatically inserted in
real time on all lines.
I do not think that you can get this with the live update, but you can
bind a macro to do "Prefixing" operations, and there you can have the
macro raise a dialog to prompt for the text once. That hides away any
search and replace things.
OK. I'll see what I can do. I need to learn nedit macro language first ...
Post by Aaron W. Hsu
You can also use a UNIX filter. I have also done a keyboard recording for
this sort of thing.
I don't see how I can use a UNIX filter to do the job.
For keyboard recording, I don't think it will work as the text can change
each time.
Post by Aaron W. Hsu
Aaron W. Hsu
--
Programming is just another word for the lost art of thinking.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Aaron W. Hsu
2011-02-17 18:33:43 UTC
Permalink
Post by eric.bouyoux
OK. I'll see what I can do. I need to learn nedit macro language first
I have the following in my nedit.rc file:

Prefix:Ctrl+0:p:R: {\n\
res = string_dialog("Enter prefix: ", "OK")\n\
replace_in_selection("^", res, "regex")\n\
}\n
Post by eric.bouyoux
I don't see how I can use a UNIX filter to do the job.
You pass it to a program that does a find and replace. There are also some
prewritten UNIX utilities that do things like prefixing and line wrapping.
Post by eric.bouyoux
For keyboard recording, I don't think it will work as the text can change
each time.
You are just recording the keystrokes, so as long as you use keystrokes
that suit your specific needs each time, then you are okay. For example,
if the column is the first one, then I might record the following: <word>
+ Down + Home. Then I just repeat that learned set of strokes for each
line I care about.

Aaron W. Hsu
--
Programming is just another word for the lost art of thinking.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
eric.bouyoux
2011-02-18 14:02:12 UTC
Permalink
Post by Aaron W. Hsu
Post by eric.bouyoux
OK. I'll see what I can do. I need to learn nedit macro language first
Prefix:Ctrl+0:p:R: {\n\
res = string_dialog("Enter prefix: ", "OK")\n\
replace_in_selection("^", res, "regex")\n\
}\n
Hi,

This macro works in some particular cases but it does not when the
selection is done with Ctrl+Left Mouse AND the selection does not start at
the beginning of the lines.
I made it work by doing the following :

replace_in_selection("(.)", res"\\\\1", regexp")\n\

BUT, I need to select only ONE character : (.+) does not do the job.
BUT, it does not work if I select one 'character' inside a 'TAB'
character.

Thank you for your help.

Eric Bouyoux.
Post by Aaron W. Hsu
Post by eric.bouyoux
I don't see how I can use a UNIX filter to do the job.
You pass it to a program that does a find and replace. There are also some
prewritten UNIX utilities that do things like prefixing and line wrapping.
Post by eric.bouyoux
For keyboard recording, I don't think it will work as the text can change
each time.
You are just recording the keystrokes, so as long as you use keystrokes
that suit your specific needs each time, then you are okay. For example,
if the column is the first one, then I might record the following: <word>
+ Down + Home. Then I just repeat that learned set of strokes for each
line I care about.
Aaron W. Hsu
--
Programming is just another word for the lost art of thinking.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Eric Bouyoux
2011-02-19 07:49:48 UTC
Permalink
Hi,

Finally, the macro works fine for the person to whom I proposed it.
So thank for your help.

Regards.

Eric Bouyoux.
Post by eric.bouyoux
Post by Aaron W. Hsu
Post by eric.bouyoux
OK. I'll see what I can do. I need to learn nedit macro language first
Prefix:Ctrl+0:p:R: {\n\
res = string_dialog("Enter prefix: ", "OK")\n\
replace_in_selection("^", res, "regex")\n\
}\n
Hi,
This macro works in some particular cases but it does not when the
selection is done with Ctrl+Left Mouse AND the selection does not start at
the beginning of the lines.
replace_in_selection("(.)", res"\\\\1", regexp")\n\
BUT, I need to select only ONE character : (.+) does not do the job.
BUT, it does not work if I select one 'character' inside a 'TAB'
character.
Thank you for your help.
Eric Bouyoux.
Post by Aaron W. Hsu
Post by eric.bouyoux
I don't see how I can use a UNIX filter to do the job.
You pass it to a program that does a find and replace. There are also
some
Post by Aaron W. Hsu
prewritten UNIX utilities that do things like prefixing and line
wrapping.
Post by Aaron W. Hsu
Post by eric.bouyoux
For keyboard recording, I don't think it will work as the text can
change
Post by Aaron W. Hsu
Post by eric.bouyoux
each time.
You are just recording the keystrokes, so as long as you use keystrokes
that suit your specific needs each time, then you are okay. For example,
<word>
Post by Aaron W. Hsu
+ Down + Home. Then I just repeat that learned set of strokes for each
line I care about.
Aaron W. Hsu
--
Programming is just another word for the lost art of thinking.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Lester M. Petrie Jr.
2011-02-17 14:19:54 UTC
Permalink
Post by eric.bouyoux
Hi,
Somebody I work with is using nedit. His preferred text editor is
Ultraedit but we don’t have it installed at work.
He would like to do the following (I explained him how to do it with
regular expression and the Replace menu, but it can be interesting anyway)
Line1
Line2
Line3
<added text>Line1
<added text>Line2
<added text>Line3
Select all first characters of each line by column (with Ctrl + Left
mouse)
Then enter the text to add once. This text is automatically inserted in
real time on all lines.
Is there a way to do that THIS WAY with Nedit ?
Regards.
Eric Bouyoux.
Do the above select, then do a Ctrl-R (or click find-replace). In the find
line, enter
^(.)
in the replace line enter
<added text>\1
toggle regular expression and make sure replace all is toggled.
--
Lester M Petrie
Oak Ridge National Lab
865-574-5259
--
NEdit Discuss mailing list - ***@nedit.org
http:/
Continue reading on narkive:
Loading...