views:

139

answers:

6

Does anyone know any cool text editing program for easy code translation? I have some code like

 public var distance:Number;
 public var blurX:Number;
 public var blurY:Number;

I need to transform it into

public double distance;
public double blurX;
public double blurY;

So, I want to say to that text editor something like this to do this job

“COMMAND::Find_ALL: var *:Number; COMMAND::Replace_ALL: double *;”

Of course I would like some UI for that but it is not so important.

If it will be able to do such operation on multiple documents it would be big plus.

BTW: I want it for translation from Action Script 3 to C#.

PS: If there is no such program but you can write it, such action would be appreciated, if you cannot or do not want to just do not say anything!

+2  A: 

I would use Notepad++ Get it free here and build some macros to do it.

Jeremy Morgan
+4  A: 

Almost looks like you're wanting to reinvent RegEx. Any IDE and framework worth its salt these days supports regex. All you need to do is run regex replaces on your source to get the result you want.

Paul Sasik
A: 

For something like this, I would use a regular expression to do the replacement. If I don't want to leave my editor, I can do this from within UltraEdit, which happens to be my personal favorite. Many editors should be up to the task, though.

Joe Suarez
A: 

Jedit is a free text editor that has a pretty powerful built in macro language that could handle this job.

JayG
A: 

I guess someone will complain if I suggest sed or any vi variant that are really up the task...

With sed:

sed -i -e 's/var \(.*\):Number/double \1/' input_file

The same substitution pattern can be used within vi (at least any vim variant). Using sed has the great advantage that it is command line (I know you asked for an UI) but it can be easily scripted to take a set of files (which you also asked for).

David Rodríguez - dribeas
A: 

The following regular expression search and replace will do what you want.

Just search for this regexp:

public var (.*):Number;

and replace it with this:

public double \1;

Most text editors these days can do a regular expression search and replace.

jussij