1

I work on Sublime Text 3 and I've installed many snippets for different PHP frameworks for example Codeigniter and Laravel.

Is there any way I can select which snippets to enable for a project? As in if I work on Laravel, the Codeigniter snippets shouldn't show and vice versa?

2 Answers 2

1

No, this is isn't possible. There is a feature request for snippet exclusion patterns.

A workaround is to separate the snippets into individual packages, then use Package Control to enable and disable the packages on-the-fly (via the Command Palette Ctrl+Shift+P).

Create individual packages in the following layout:

\
+-Packages
      +- snippets_package_name_a
      |       \-*.sublime-snippet
      +- snippets_package_name_b
      |       \-*.sublime-snippet
      ...

Find the Packages directory: Menu > Preferences > Browse Packages....

Open the Command Palette: Ctrl+Shift+P

Type the commands:

  • Package Control: Enable Package
  • Package Control: Disable Package
Sign up to request clarification or add additional context in comments.

2 Comments

Actually, this is very easy to do. See my answer.
How do I 'separate the snippets into individual packages'? I'm unable to find the builtin snippets (the ones that ship with sublime).
0

Yes, this is quite simple to do. Assuming you have a .sublime-project file defined for your current project, select Project → Edit Project, and in the "settings" dict add "ignored_packages": [] and in the array add the package(s) you want to ignore. Here's an example:

{
    "folders":
    [
        {
            "follow_symlinks": true,
            "path": "/home/mattdmo/Projects/laravel_project_1"
        }
    ],
    "settings":
    {
        "ignored_packages": [
            "CodeIgniter Snippets",
            "CodeIgniter Utilities"
        ]
    }
}

The named packages will only be ignored in this project. For a CodeIgniter project, just add your Laravel-related packages.

3 Comments

This doesn't work for me (Linux Build 3125). Would it override the User defined "ignored_packages" or add to it?
I think this won't work because some settings seem to be global only: forum.sublimetext.com/search?q=ignored_packages. It makes sense with some settings e.g. would it merge or overwrite the user defined settings, how would multiple projects with differing ignored packages work, etc.
That's very sad but I must agree with @GerardRoche . Unfortunately it doesn't work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.