Ok, this isn't quite an answer, but why not using editor macros?

Just a thought, don't flame me.

Paulo Jorge Duarte Kh
paulo.koch / gmail.com