sublime插件开发教程4

写几个简单的例子详解下

import sublime
import sublime_plugin
 
 
class ExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        sels = self.view.sel();
        for sel in sels:
            print(sel);

然后选中文字 输出看到如下

 

 从第8个字符到第3个字符  为什么不是(3,8)呢 因为我是从后面往前面选的

import sublime
import sublime_plugin
 
 
class ExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        sels = self.view.sel();
        for sel in sels:
            print(sel.end());

那么输出的就是8 了

原文地址:https://www.cnblogs.com/newmiracle/p/11966090.html