Automated D code editing?

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Fri Oct 12 13:36:55 PDT 2012


On Fri, 12 Oct 2012 19:51:02 +0200
Lubos Pintes <lubos.pintes at gmail.com> wrote:

> Hi,
> I am still playing with DGUI library. Besides other things, I would
> like to convert enum names from 
> "THIS_STUPID_NAMING_CONVENTION_WHICH_I_ABSOLUTELY_HATE" to
> "thisGoodOne". Obviously I could do this by hand but it is a bit time
> consuming. Any tool / hack to help me with this?
> Thank

If you're on Windows and know Python, you could download Programmer's
Notepad 2 <http://www.pnotepad.org/> which supports scripting in
Python to make custom macros/tools/extensions/etc. Maybe someone
already made such a PN2 script, I don't know. It does already have a
built-in keyboard shortcut for "convert to lowercase" (ctrl-u), which
might at least help. Then you could manually uppercase the letter
after each _ and then regex search/replace to get rid of the _'s.

IIRC, Visual Studio has a similar scripting feature, but not in Python
(VBScript maybe? Or C#? I forget), so maybe you could do the same with
Visual-D.

Or, it would probably be pretty simple to write a little script in D
that just does a regex search for say, `[A-Z_][A-Z_]+` and then
converts each instance.

Unfortunately I don't know offhand of a tool that would do it all
automatically without code needing to be written. :(



More information about the Digitalmars-d-learn mailing list