![Sublime text editor plugins user input](https://kumkoniak.com/18.jpg)
We will implement an example input handlerĬlass SimpleCommand (sublime_plugin. # Implementing an Input Handlerīecause input handlers are using a rather generic interface,Īnd may not be the most intuitive process. While list input handlers can handle any JSON-serializable value,Īccompanied by a caption for their respective list entry. Text input handlers always forward the entered text to the command,
- list input handlers providing a list of options for the user to choose from.
- text input handlers accepting arbitrary text input,.
- There are currently two types of input handlers: You can use the above View Package File command Queries the user for a new file name for the active view. Provides a list of all resource files inside the Packages folder to open. (command names are for the Command Palette): Command nameĮvaluates a given Python expression (usually numeric). The following commands provided by Sublime Text's Default package
Input Handlers have been added in build 3154Īnd were first available on the stable channel in version 3.1. ( Window.show_input_panel and Window.show_quick_panel)įor a unified user experience in a single component. They replace the older method of input and quick panels 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.To query a user for one or multiple input parameters 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.