The syntax is similar to the menu file you just edited: [ To make the command show up in the Commands Palette, you need to create a file named Default.sublime-commands (or edit an existing one) in the User folder. This will assign the shortcut ⌃ ⇧ F to this command. To assign a keyboard shortcut, open and edit the file Default (OSX).sublime-keymap on OS X, or the equivalent for other systems, and enter the following: [ See step 11 here for a more detailed explanation why that is. This will insert the filter command call (essentially, filter is transformed to FilterCommand().run(…) for the plugin call and Filter for the menu label) just below the wrap command. Add or set the following text to that file: [ If a file called Main.sublime-menu doesn't exist, create it. To add this plugin to the Edit menu, select Preferences… » Browse Packages and open the User folder. Save as filter.py in ~/Library/Application Support/Sublime Text 2/Packages/User Integration with UI Sublime.active_window().show_input_panel("Filter file for lines containing: ", cb, done, None, None) # if there's no non-empty selection, filter the whole documentĬlass FilterCommand(sublime_plugin.TextCommand): In Sublime Text 2, select Tools » New Plugin and enter the following text: import sublime, sublime_plugin Adding basic filtering TextCommand plugin You can create new commands (called Plugins) and make them available from the UI.
Sublime Text 2 is an extensible editor with a Python API.