How to change file type in a macro/addon?

Hello, I have a macro that does a few replaceAllInMacro on the current file. I’ve noticed that these complete about an order of magnitude faster if running against plain text files than against code files. Same file, just change the type to Text and it runs in a tenth the time. Is there a way in my macro to change the type of the current file to ‘Text’, run my find/replaces, then change it back?

Thanks,
Ben

Hi @zir39,

You can just add this line to your macro:

ko.views.manager.do_ViewAs('Text');

and you should be good to go. You can try it out in the Javascript Shell that comes in the Komodo Extension Developer add-on.

  • Carey

1 Like

Fantastic, I figured there had to be an easy way to do it, but I couldn’t find it in the API documentation. Thanks a lot!

Ya, we’re always here to help but if you’re interested, you can always use the DOM Inspector Addon to inspect various aspects of Komodo and see what they do.

eg. Inspect the file type popup list in the status bar and see what it does when you change a file type.

Cheers!

  • Carey