PDA

View Full Version : Text editor suggestion?



Peegee
07-18-2008, 10:52 PM
Say I wanted to append a string to the end of every line and um...prepend a string to each line as well. What editor would you use to make it super duper easy?

Thanks in advance (also I'm going to check the suggest a program thread right after this)

Nominus Experse
07-18-2008, 11:12 PM
I don't know if it does what you wish or not, but I have found TED Notepad to have more options than I can list. May wish to check that out.

o_O
07-18-2008, 11:14 PM
Really, there are a million different "advanced text editors" which are mostly capable of the same things, but my choice would be <a href="http://www.scintilla.org">SciTE</a>.

First you have to hit Ctrl+H to bring up the replace dialog. Second, check the "evaluate backslash expressions" box. Third, replace the text "\r\n" with "[append string]\r\n[prepend string]". :p

Rantz
07-19-2008, 12:21 AM
I don't think any editor will make that super duper easy. If you do stuff like that often I recommend learning basic regular expressions and using a tool like SciTE or Notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm).

Edit: Actually, it's pretty easy to record a macro in Notepad++ and running a loop on that macro which will do the job.

Editga: Apparently Notepad++ also has a "column editor" which lets you insert text into all rows on a given column. That makes prepending super duper easy, but it pads the shorter lines if you try to append. There's probably a way around that.

crono_logical
07-19-2008, 10:23 AM
Surely this can be done with a simple one line command using sed at a command line? :D This works for me:

<pre>sed 's/^.*$/prepend text&append text/' inputfile.txt &gt; result.txt</pre>
That'd get around the problem of it not altering the first and possibly last lines in the file using face's method :monster:

Peegee
07-21-2008, 03:11 PM
Surely this can be done with a simple one line command using sed at a command line? :D This works for me:

<pre>sed 's/^.*$/prepend text&append text/' inputfile.txt &gt; result.txt</pre>
That'd get around the problem of it not altering the first and possibly last lines in the file using face's method :monster:

I'm getting 'not enough arguments' error.

crono_logical
07-21-2008, 06:49 PM
what OS you trying it on? syntax may vary, but that works in cygwin for me :p

Peegee
07-21-2008, 08:51 PM
what OS you trying it on? syntax may vary, but that works in cygwin for me :p

windows xp ? :D

crono_logical
07-21-2008, 09:30 PM
Install cygwin then then try from the cygwin prompt instead of DOS prompt, since I did it from cygwin on WinXP :D