Sublime Forum

Replace default script snippet for javaScript

#1

The default snippet for script is <script type="text/javascript"></script>

But I want to create two snippets like<script></script> and <script src=""></script> when I type “script”.

I know how to replace a snippet but I cannot find this file. Anyone?

0 Likes

#2

It’s likely in the default HTM package. Have you tried OverrideAudit to create an override?t

0 Likes

#3

May I know where is the default JavaScript package? I’m not using the OverrideAudit but the traditional way of replacing a snippet.

0 Likes

#4

This looks like it is a completion in a HTML file. It is not trivial to replace that, because it’s not a snippet, but instead comes from a (built-in) plugin, namely the HTML/html_completions.py file. The completion for the script tag is hardcoded here: https://github.com/sublimehq/Packages/blob/a577e6b006d7c0f03f475283956d56cb43927c8e/HTML/html_completions.py#L132

I think you could only disable all completions in the syntax specific settings for HTML (https://github.com/sublimehq/Packages/blob/a577e6b006d7c0f03f475283956d56cb43927c8e/HTML/HTML.sublime-settings#L3), or create an override for the entire Python file. And of course you can always add your own snippets with a unique trigger, which should take precedence if it matches directly.

0 Likes