@agoago (ago) posted a new topic, subject "Is there extension to create folder tree from current project". It read:

   I often draw my project folder structure like this
    
    app  
    | controller  
    | view  
    | asset  
    | css  
    | js
    
    which is a pain to do from time to time. I there a sublime plugin that can do this for us?

@OdatNurd (Terence Martin) replied

    I did a little searching around but didn't find anything dedicated to this particular task; I may not have been searching for the correct keywords though, so it's possible that there is some plugin that does this along with other things and I just didn't find it.
    
    In any case, I'm always up for an exercise to learn a little more about sublime, so I did a bit of poking and came up with the following simple plugin (the code that actually generates the tree I got from this stackoverflow post):
    
    * * *
    [code] 
        import sublime, sublime_plugin, os
        
        # Append a tree view of a root path to the current view;
        # probably you don't want to bind a key to this one
        class DisplayTreeCommand(sublime_plugin.TextCommand):
            def run(self, edit, rootPath):
                for root, dirs, files in os.walk(rootPath):
                    level = root.replace(rootPath, '').count(os.sep)
                    indent = ' ' * 4 * (level)
                    self.view.insert (edit, self.view.size (),
                        '{}{}/\n'.format(indent, os.path.basename(root)))
                    subIndent = ' ' * 4 * (level + 1)
                    for f in files:
                        self.view.insert (edit, self.view.size (),
                            '{}{}\n'.format(subIndent, f))
        
        # Create a new scratch buffer and insert a textual tree of
        # the current project path into it
        class DisplayProjectTreeCommand(sublime_plugin.WindowCommand):
            def run(self):
                # Only do stuff if there is a project
                varList = self.window.extract_variables ()
                if "project_path" in varList:
                    # Create a new scratch file to put the tree in
                    outView = self.window.new_file ()
                    outView.set_scratch (True)
                    outView.set_name ("Project Tree")
        
                    # Do it
                    outView.run_command ('display_tree', {"rootPath": varList["project_path"]})
                else:
                    self.window.status_message ("No project defined")
        
    [/code]
    
    Stored in `Packages/User/display_project_tree.py` (use `Preferences > Browse Packages...` to find that location if needed).
    
    A sample key binding would be:
    [code] 
            {"keys": ["ctrl+alt+shift+t"], "command": "display_project_tree"}
        
    [/code]
    
    This uses the naive approach of just displaying the complete tree rooted at the location where the project is stored. In particular, it does not handle extra paths added or excluded from the project, handle the case where the project file is in a different location outside of the project tree and it (probably) doesn't display the tree in exactly the format that you want, but it should be a good starting point.

To which @fico replied

    `window.extract_variables()[ "project_path" ]` returns the path that contains project data ( `sublime-project` & `sublime-workspace` files ), rather than the actual project path.
    
    The updates below should fix that:
    [code] 
        class DisplayProjectTreeCommand( sublime_plugin.WindowCommand ):
        	def run( self ):
        
        		projectData = self.window.project_data()
        		if not projectData:
        			self.window.status_message( "No Project Defined" )
        			return
        
        		projectPath = next( folderDict for index, folderDict in enumerate( projectData[ "folders" ] ) if "path" in folderDict )[ "path" ]
        		projectName = self.window.extract_variables()[ "project_base_name" ]
        
        		outView = self.window.new_file()
        		outView.set_scratch( True )
        		outView.set_name( projectName + " (Folder Tree)" )
        		outView.run_command( 'display_tree', { "projectPath": projectPath } )
        
    [/code]

Then @agoago (ago) said

    @OdatNurd I copied the code and create the plugin. It doesn't seem to work, pressing the shortcut combination will not happening anything.
    
    we save the plugin in the package folder or user folder?

Then @OdatNurd (Terence Martin) said

    You should save it in the `Packages/User` folder. The name doesn't matter as long as it has the `.py` extension.

So @agoago (ago) replied

    that's cool


{'source': 'discourse', 'url': 'https://forum.sublimetext.com/t/is-there-extension-to-create-folder-tree-from-current-project/21370', 'title': 'Is there extension to create folder tree from current project', 'views': 2463, 'has_accepted_answer': False, 'word_count': 556, 'like_count': 4, 'reply_count': 2, 'participant_count': 3, 'posts': 6, 'tags': '', 'author': '@agoago (ago)', 'participants': '@agoago (ago), @OdatNurd (Terence Martin), @fico', 'image_url': '', 'created_at': '2016-07-02T05:17:48.716Z', 'last_posted_at': '2016-07-16T15:58:48.512Z'}