我为Sublime Text编写了一个简单的插件,它可以在光标位置插入标记或将标记环绕选定的文本:
import sublime, sublime_plugin
class mySimpleCommand(sublime_plugin.TextCommand):
def run(self, edit):
sels = self.view.sel()
for sel in sels:
sel.start = sel.a if (sel.a < sel.b) else sel.b
sel.end = sel.b if (sel.a < sel.b) else sel.a
insert1Length = self.view.insert(edit, sel.start, '<tag>')
self.view.insert(edit, sel.end + insert1Length, '</tag>')
但是在插入标记之后,如何移动光标呢?我查看了https://www.sublimetext.com/docs/2/api_reference.html中的API文档和几个示例插件,但仍然未能解决这个愚蠢的问题。有人能帮忙吗?在
下面是一个如何将光标移动到行尾的示例。应该怎样概括才是显而易见的!在
关于API reference。在
我也遇到了同样的问题——在插件中添加文本后,将光标移到一行的末尾。 我用塞尔吉奥夫的暗示修复了它:
对我有用。在
相关问题 更多 >
编程相关推荐