Skip to content

Instantly share code, notes, and snippets.

@jacob-ogre
Created June 12, 2013 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacob-ogre/5769414 to your computer and use it in GitHub Desktop.
Save jacob-ogre/5769414 to your computer and use it in GitHub Desktop.
NerdTree-like behavior for Sublime Text 2
import sublime, sublime_plugin
class NerdTreeCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("toggle_side_bar")
self.window.run_command("focus_side_bar")
@jacob-ogre
Copy link
Author

I use 'nt' in Vim to toggle NerdTree; in ST2, to avoid any conflict, use 'nt' to open and 'tn' to close the sidebar (and return focus to group 0).

@srghma
Copy link

srghma commented Dec 25, 2016

import sublime, sublime_plugin

class NerdTreeCommand(sublime_plugin.WindowCommand):
    def run(self):
        was_visible = self.window.is_sidebar_visible()
        self.window.run_command("toggle_side_bar")
        if was_visible:
          self.window.run_command("focus_group", { "group": 0 })
        else:
          self.window.run_command("focus_side_bar")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment