mikemaccana
mikemaccana

Reputation: 123198

How can I make a Sublime Text project file to only show certain folders?

SublimeText has a project-settings file that includes a folder_include_patterns option.

I have a folder called (my app name).project-settings (which according to some research, is the correct name for the file) in the top level of my project. I am trying to make Sublime not show all the files under node_modules except my-module:

{
  "folders": [
    {
      "path": "node_modules",
      "folder_include_patterns": [
        "my-module"
      ]
    }
  ]
}

However SublimeText still shows all the files under node_modules. How can I make a Sublime Text project file to only show certain folders?

Upvotes: 0

Views: 605

Answers (2)

mikemaccana
mikemaccana

Reputation: 123198

My syntax is correct, but making the file isn't enough to make a dir into a project.

Since there is no 'new project' button in Sublime, you can make a folder with:

  • Open the folder in Sublime.
  • Click Project > Save Project As

This makes:

your_project.sublime-project

{
  "folders": [
    {
      "path": "."
    },
    {
      "path": "node_modules",
      "folder_include_patterns": [
        "my-module"
      ]
    }
  ]
}

your_project.sublime-workspace (left as defaults)

Additionally: you must open the project from the Project menu (otherwise it will still be a folder and ignore the .sublime-project file).

Upvotes: 0

Jon Surrell
Jon Surrell

Reputation: 9637

I assume you don't want to ignore all the other modules in node_modules. You could ignore your node_modules directory and include your module as another folder.

{
  "folders":
  [
    {
      "folder_exclude_patterns":
      [
        "node_modules",
      ],
      "path": "."
    },
    {
      "path": "node_modules/mymodule"
    },
  ]
}

Upvotes: 1

Related Questions