Question

I have this code snippet for C language:

File name: c.sublime-snippet
File path: /home/admin/.config/sublime-text-3/Packages/User

Code:

<snippet>
    <content><![CDATA[

#include <stdio.h>

main(){
    ${1}
}
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>init</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.c</scope>
</snippet>

After saving this file at the specified path(Check above) I still can't access the snippet with the specified tag init. I have tried this on windows and it worked fined. Any idea where to save the file c.sublime-snippet so it works on ubuntu ? Thank you

Was it helpful?

Solution

All user-generated files should be stored in the Packages/User directory. So, in your case, save it as /home/admin/.config/sublime-text-3/Packages/User/c.sublime-snippet.

Also, it's generally a good idea to name snippets according to their tabTrigger, as you may eventually write multiple snippets dealing with C. So, you can rename it as init.sublime-snippet if you choose.

EDIT

Based on your edit indicating that the snippet was already saved in Packages/User, the only other likely reason for its failure is that the scope source.c was not actually in effect. You need to make sure to set your file's syntax to C in order for this scope to work - C++ is source.c++.

OTHER TIPS

In ubuntu 16.04 and sublime text 3, the snippets are stored at:

~/.config/sublime-text-3/Packages/User

The .config folder is hidden by default, so you won't be able to see it in your files application.

You can see it in terminal by doing ls -a or ll.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top