Leverage Sublime project folders to ease your work

October 12, 2016

One Sublime Text feature I have found invaluable is having multiple folders associated with a project. This makes it easy to find the files I frequently work on and makes it trivial to create new files.

When I’m working on a web development project, I’ll make a new Sublime project out of the project’s root folder, then add folders for the templates, sass, and JavaScript folders. This way, I have four folders on the sidebar, three of which give me quick access to the files I edit most. The fourth allows me to drill down from the site’s root to find any other file I might need.

Because these folders I create are nested inside of the project’s root folder, I get duplicate search results any time there are matches in these additional folders. To remedy that, I edit the project file (by going to Project > Edit Project) and add these folders into the parent’s folder_exclude_patterns property.

For example, below is a Sublime project file with a root folder and a folder pointing to the scss folder. The scss folder will be named “styles” and listed first in the side bar.


// in myProject.sublime-project
{
  "folders": [
    {
      "path": "assets/scss",
      "name": "styles"
    },
    {
      "path": ".",
      "folder_exclude_patterns": ["scss"]
    },
  ]
}

Another way to take advantage of these additional folders is with the AdvancedNewFile package. With that package installed, these additional folders become tab-completed shortcuts to create new files in them. For example, let’s say I wanted to create a new .scss file at project/assets/scss/components/_foo.scss . I can quickly accomplish this through my keyboard by:

  1. command option n (for advanced_new_file_new command)
  2. then type scs [tab] , which autocompletes to “scss:”
  3. followed by c [tab] to autocomplete components/
  4. then type _foo.scss .

Finally, AdvancedNewFile also gives you the ability to create boilerplate code for your new files. For instance, when I create a new .scss file, it’ll add an empty class at the top of this new file, ready for me to customize for my needs.

Are there any other ways you’ve used Sublime folders to your advantage? Let me know!

© 2024 Everyday Superpowers

LINKS
About | Articles | Resources

Free! Four simple steps to solid python projects.

Reduce bugs, expand capabilities, and increase your confidence by building on these four foundational items.

Get the Guide

Join the Everyday Superpowers community!

We're building a community to help all of us grow and meet other Pythonistas. Join us!

Join

Subscribe for email updates.