Sublime text设置快捷键让编写的HTML文件在打指定浏览器预览

作者:浪人
链接:https://www.zhihu.com/question/27219231/answer/43608776
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

1,按Ctrl+`调出console(注:安装有QQ输入法的这个快捷键会有冲突的,输入法属性设置-输入法管理-取消热键切换至QQ拼音)

2,粘贴以下代码到底部命令行并回车:(ST3版本)import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'Package Control' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)(ST2版本)import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'Package Control' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

3,在Perferences->package settings中看到package control这一项就待变安装成功啦。

4,安装SideBarEnhancements插件ctrl+shift+p —> Install Package —> 找到SideBarEnhancements

5,然后再配置预览快捷键就行了---------------------------------------预览快捷键配置--------------------------同学的答案说下自己设置成功的步骤。(话说这么简单的事情花费了我两个小时也是醉了,以后养成有问题先来知乎搜索的习惯。。。。)

第一步。Preferences—Key Bindings—User.然后就跳出一个空白页面。

第二部,将以下代码键入。// chrome
{ "keys": ["f2"], "command": "side_bar_files_open_with",
        "args": {
            "paths": [],
            "application": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
            "extensions":".*"
        }
 },

// firefox
{ "keys": ["f3"], "command": "side_bar_files_open_with",
         "args": {
            "paths": [],
            "application": "D:/Program Files (x86)/Mozilla Firefox/firefox.exe",
            "extensions":".*"
        }
},

// ie
 { "keys": ["f4"], "command": "side_bar_files_open_with",
         "args": {
            "paths": [],
            "application": "C:/Program Files/Internet Explorer/iexplore.exe",
            "extensions":".*"
        }
}
其中“keys”是指定快捷键,替换成自己想要的。application是你浏览器在电脑上的目录地址,替换了就OK了。然后保存更改就。然后就搞定了。Enjoy Coding !

上一篇:ubuntu sublime text key


下一篇:ubuntu Sublime Text 2编辑器安装