*_js.php as javascript style
-
Hi,
It’s possible to auto set the language as javascript when the file ends as _js.php? Hi already set in the Style Configurator -> user extensions _js.php but it didn’t work… It would save me a lot of time.
Regards!
-
Ummm… all of that is based upon a file’s extension. The extension is (roughly) defined as whatever follows the final
.in a file’s pathname, after the final path separator (e.g.\). By now you should have your answer, but in case you don’t I’ll give it to you: What you are asking isn’t reasonably possible. -
I have reconsidered. I think a script could do it. If you are interested in, say a Pythonscript solution, reply back.
-
“a Pythonscript solution”
It would be great. I googled but I don’t even know how to start… :/
Thanks for reply.
Regards. -
So taking a nod from this recent posting, we can tweak what is found there, to obtain:
# -*- coding: utf-8 -*- from Npp import editor, notepad, NOTIFICATION, MENUCOMMAND def callback_npp_FILESAVED(args): for (filename, bufferID, index, view) in notepad.getFiles(): if bufferID == args['bufferID']: if filename.endswith('_js.php'): notepad.menuCommand(MENUCOMMAND.LANG_JS) break notepad.callback(callback_npp_FILESAVED, [NOTIFICATION.FILESAVED])Which should do what you want.
-
Hi, thanks for the script. It opened a new world to me :)
I Changed the enumerator [NOTIFICATION.FILESAVED] to [NOTIFICATION.FILEOPENED] and It worked but with a problem: if I do not have any opened file it work well, if I have, it change the language to the first opened file… So, I just added notepad.activateFile(filename) before the menu command and it work ok :)
Thanks!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login