Chinaunix首页 | 论坛 | 博客
  • 博客访问: 21036
  • 博文数量: 13
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 155
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-14 13:21
文章分类
文章存档

2015年(13)

我的朋友

分类: Python/Ruby

2015-02-05 08:29:13

        今天开始用sublime text3,配置到最后,发现没有一个理想的可以打开服务器指定页面的插件,索性自己写了个

点击(此处)折叠或打开

  1. import sublime, sublime_plugin
  2. import webbrowser


  3. class BrowseAtRemoteCommand(sublime_plugin.TextCommand):
  4.     def run(self,edit,remote_path=''):



  5.         window = sublime.active_window()
  6.         window.run_command('save')
  7.         url = self.view.file_name()

  8.         folders=window.folders()


  9.         relativePath=""
  10.         for path in folders:
  11.             nPos=url.find(path)
  12.             if nPos==0:
  13.                 
  14.                 length=len(path);

  15.                 relativePath=url[length:]

  16.                 print ("相对路径:"+relativePath)


  17.         if (relativePath=="" or remote_path==""):        
  18.             webbrowser.open_new(url)
  19.         else:
  20.             webbrowser.open_new(remote_path+relativePath)
        调用方法:在按键绑定里面

点击(此处)折叠或打开

  1. { "keys": ["f12"], "command": "browse_at_remote",
        "args": 
        {
            "remote_path": ""
        } 
    }
        当然也可以不给它参数,那么打开的就是本地的页面

点击(此处)折叠或打开

  1. { "keys": ["f12"], "command": "browse_at_remote"}



阅读(443) | 评论(0) | 转发(0) |
0

上一篇:使用OpenDHCPServer和OpenTFTPServer搭建pxe环境

下一篇:没有了

给主人留下些什么吧!~~