Tell Sublime Text to ignore everything in .gitignore?

后端 未结 3 1215
遇见更好的自我
遇见更好的自我 2021-02-01 00:37

Vim has this great plugin to convert the current project\'s .gitignore into a syntax understandable by Vim and from there exclude all those files from opening.

相关标签:
3条回答
  • 2021-02-01 00:55

    I created a quick-and-dirty plugin, sublime-gitignorer, to solve exactly this problem.

    It is currently tested on Ubuntu and Windows in Sublime Text 2 and 3. I expect it will also work on any other Linux distro or on Mac.


    To install, assuming you have package control, just:

    • Press CTRL+SHIFT+P (CMD+SHIFT+P on Mac)
    • Select "Install Package"
    • Search for the Gitignored File Excluder and press Enter.

    Alternatively, if you don't have package control you can copy gitignore_plugin.py to your Packages directory, which you can locate by selecting Browse Packages... from the Preferences menu in Sublime. You should really get Package Control instead, though - it's useful.


    I'm not kidding when I say this plugin is dirty. The way it works is that the plugin, every five seconds:

    • Checks for Git repos located within your open folders
    • Asks Git what paths are ignored in each of those repos
    • Adds those paths to the file_exclude_patterns and folder_exclude_patterns settings.

    Seems to work okay for most users, though - at least as long as the folders you're opening in Sublime aren't too huge. The presence of giant folders (e.g a typical node_modules folder) can, in combination with this plugin, slow Sublime to a crawl.

    Anyone looking to contribute or report bugs should check out the issues page.

    0 讨论(0)
  • 2021-02-01 00:58

    Assuming you have Sublime 3 and already installed Package Manager:

    1. add repo https://github.com/apc999/sublime-text-gitignore
    2. add package sublime-text-gitignore
    3. use menu item : File->Exclude Git-ignored

    Have fun:)

    0 讨论(0)
  • 2021-02-01 01:13

    You can get a list of all the ignored files with

    git ls-files --others -i --exclude-standard

    and then add this to your file_exclude_patterns in Sublime Text as bheklilr suggested.

    0 讨论(0)
提交回复
热议问题