Sublime Forum

Few questions regarding plugin creation

#1

First off, I’ve made some keybinds and small plugins to allow for a couple things I was missing, Tabbing out of the auto closed brackets - “”{}{]()’’ - and dot completion, “.” to do autocomplete and placing the dot directly after for a quick and easy (eg. typing: sys. would give you “system.” ready for whatever you needed. Before I put them up anywhere I need to clean them up and have a few questions.

  1. Can I use commands like “following_text”: blah blah blah in python or do those particular commands only work in the keybinds file?
    a. How can I use “following_text” with more than one char at a time but only requiring one of them. eg. I want to submit an action IF the following char is " or ’ or ( or … etc.

mm… i think that’s all for now. Appreciate any help I can get and hopefully these will come in handy for others as well when I’m finished.

0 Likes

#2

I do not know of a way to access the query context stuff (like following_text) from python. I’m curious why using it from the keybind file is not sufficient for you.

Typically you would just use the normal view methods to access the file contents. So, for example:

c = view.substr(view.sel()[0].begin())
if c in ']{}\'"':
    # The next character is a bracket or quote.    

Also, things like snippets would handle things like “sys.” -> “system.”. You don’t need to drop to Python for that.

0 Likes