Sublime Forum

Insert snippet from menu

#1

Hi,

I’m trying to add a menu (under Tools|Packages) for my LaTeX package. Almost everything works (looking at the default menu file helped me understand the format reasonably well), with one exception. I cannot seem to create a menu item that adds a snippet. I am trying:

<item caption="Emphasize" command="insertSnippet emphasize"/>

where emphasize is a snippet in the LaTeX plugin. Issuing

view.runCommand("insertSnippet emphasize")

in the console works as expected. What am I doing wrong?

Thanks!
M

0 Likes

#2

I’m surprised typing it in the console works: the insertSnippet command should take a package relative path, such as “insertSnippet Packages/LaTeX/Cases.sublime-snippet”. It’s case-sensitive, so that may be biting you.

0 Likes

#3

I must have been asleep at the keyboard :wink: Of course you are right: it doesn’t work even from the console, and the menu item is dimmed. Providing the package-relative path as per your suggestion fixed things! I’ll upload the change with the next commit. Thanks!

0 Likes