Page 1 of 1

Run script with 2 functions on document open

Posted: 09 Apr 2018 10:55
by crtrubshaw
Hello, I would like to create a script which will run for each document I open and the 2 program functions I want to run are:

1. ConvertSpacesToTabsAction
2. RemoveTrailingSpacesAction

I can't do this as a macro because it forces me to stop recording and I can't find these functions anywhere in the documentation, does anybody know if this is possible?

Many thanks!

Re: Run script with 2 functions on document open

Posted: 09 Apr 2018 13:38
by pjj
If you never use tabs nor trailing spaces (and have your settings set accordingly) and just want to sanitize some docs, you could use a simplest script triggering editor to mark document as changed, to e.g. set caret at 1,1, add any character, delete it and then save document (or even change newline format and then revert it) -- and RJ TE will do the job for you. If not, take a look at Document.ReplaceAll() and ScriptUtils.RegExReplaceAll().

Re: Run script with 2 functions on document open

Posted: 09 Apr 2018 15:47
by crtrubshaw
Good thinking pjj, thanks, all I needed was to run ScriptUtils.RegExReplaceAll() twice in the script and it did exactly what I wanted.

Cheers!

Re: Run script with 2 functions on document open

Posted: 09 Apr 2018 16:29
by pjj
Cheers! :-D

Image