Search code examples
sublimetext3sublimetextsublime-text-plugin

Spaces in package names


I have read Submitting a Package instruction, and it is said that CamelCase or snake_case will make search results more accurate.

Use CamelCase or underscore_notation. Other Python packages in ST3 will be able to more easily interact with it. Additionally, the search indexer will properly split words, making search results more accurate. Obviously this does not matter if your package name is a single word or contains no Python.

However, it is not clear about which search it was said. Which one? (As I understand, it is not about the search invoked with Ctrl+F or Ctrl+Shift+F keys.)


Solution

  • The search indexer that it's referring to is the one on packagecontrol.io that allows you to search for packages. The search only matches on whole words and partial words that start with the search term you use; for example the Hermes package can be found with the search term Her but not ermes or erm.

    In order to make packages more easily searched if they contain multiple words, the indexer knows to split CamelCase and snake_case names into words to provide terms, so CoolColorScheme is more findable than coolcolorscheme.

    In addition, in Sublime a package is actually a python module, which allows other packages to reference code in them if they want. For example, you can create a custom exec command by subclassing the default one:

    import sublime
    import sublime_plugin
    
    from Default.exec import ExecCommand
    
    class MyExecCommand(ExecCommand):
       pass
    

    If you use spaces in your package name, this is made much harder as spaces are not allowed in module names. Thus this is less important if your package contains no Python code because then no other packages will be able to reference code in it anyway.