Author Topic: Batch setting document mode  (Read 4333 times)

Scott277

  • Community Member
  • Posts: 17
  • Hero Points: 0
Batch setting document mode
« on: November 16, 2009, 12:37:18 pm »
I have a long-standing PHP project that contains hundreds and hundreds (maybe even a thousand or more) PHP files.  This project was created in VSE 9? maybe.  When I go to edit a file, every single file has the document mode set to HTML, even though the file extension is PHP.  While I realize that some developers embed PHP in HTML documents, I don't.  Each PHP file is pure PHP code.

I can certainly edit each file and use the menu or command line to change the document mode but this is time consuming and irritating.  Is there a way to batch set the document mode for all PHP files in the workspace?  Or perhaps edit one of the VSE project files by hand to make the change to all files loaded into the project?  Maybe a simple VSE script that can iterate over the files and set the flag?

Like I said, I can do it by hand if needed but I'm a programmer and fundamentally lazy.  ;D

Any ideas are much appreciated and thanks.


Scott

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: Batch setting document mode
« Reply #1 on: November 16, 2009, 12:46:05 pm »
No experience doing this, so YMMV. 

You can record a macro setting a document mode to php, then process a directory listing using a for loop.

Quick & easy if it works, and you're expanding your resume at the same time.  If it doesn't work, you can come back & ask for more.  Likely, by the time you try it out, someone will have posted a macro to do that right here.

Jim

Graeme

  • Senior Community Member
  • Posts: 2748
  • Hero Points: 340
Re: Batch setting document mode
« Reply #2 on: November 17, 2009, 09:13:01 am »
Did you try changing the language association for the php extension?  In tools -> options -> languages -> file extension manager, select php in the "file extensions" list, then in the "associate with language" combo box, select php instead of html.

Graeme

Scott277

  • Community Member
  • Posts: 17
  • Hero Points: 0
Re: Batch setting document mode
« Reply #3 on: November 30, 2009, 05:36:48 pm »
Changing the language extension seems to have done the trick.  No idea how mine got mapped to HTML, unless that's the default in VSE due to mixed-mode PHP/HTML files.

Thanks for the assistance!