我的sublime配置for python

apt安装最新版sublime:
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
修改常用配置(菜单栏 - preferences - settings):
{
	"bold_folder_labels": true,
	"default_encoding": "UTF-8",
	"draw_minimap_border": false,
	"fade_fold_buttons": false,
	"file_exclude_patterns":
	[
		".DS_Store",
		"*.pid",
		"*.pyc"
	],
	"folder_exclude_patterns":
	[
		".git",
		"__pycache__",
		".idea"
	],
	"font_size": 14,
	"ignored_packages":
	[
		"Vintage"
	],
	"line_numbers": true,
	"line_padding_bottom": 3,
	"line_padding_top": 3,
	"match_selection": true,
	"save_on_focus_lost": true,
	"spell_check": false,
	"tab_size": 4,
	"translate_tabs_to_spaces": true,
	"trim_trailing_white_space_on_save": false,
	"update_check": false
}

使用tab快速输入代码片段

在菜单栏点击 tools - developer - new snippet
编辑成如下内容,并保存

<snippet>
    <content><![CDATA[import pdb;pdb.set_trace]]></content>
    <tabTrigger>pdb</tabTrigger>
    <scope>source.python</scope>
</snippet>

然后在py文件中,输入pdb后按tab键,就可以自动补全成 import pdb;pdb.set_trace

安装sublime textr3包管理工具,按ctrl+`输入以下代码:
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; 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( 'http://packagecontrol.io/' + 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)

安装插件(点击preference>package control 输入install package,回车,输入插件名称后,回车安装)

安装SublimeCodeIntel并修改配置:preference>package settings >SublimeCodeIntel > setting-user :

{
    "codeintel_language_settings": {
        "Python": {        
            "python": "/usr/bin/python",        
            "pythonExtraPaths": []    
        },    
        "Python3": {        
            "python": "/usr/bin/python3",        
            "pythonExtraPaths": []    
        }
    }
}

按ctrl+shift+space 格式化代码

安装AutoPep8,然后修改配置preference>package settings >AutoPep8> setting-user :

{
    "settings": {
        "sublimeautopep8": {
            "max-line-length": 79,
            "format_on_save": false,
            "show_output_panel": true,
            "ignore": "E24,E226,E501",
            "syntax_list": ["Python"],
            "file_menu_search_depth": 3
        }
    }
}

按ctrl+shift+8 让代码符合pep8标准

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值