Sublime Text 3 python 配置

Sublime Text 3 python 配置

Package Control 安裝方法html

  1.經過快捷鍵 ctrl+` 或者 View > Show Console 打開控制檯,而後粘貼相應的 Python 安裝代碼;python

  2.Sublime Text 3 安裝代碼並回車:shell

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())bash

  3.重啓Sublime Text 3;ide

  4.若是在Perferences->package settings中看到package control這一項,則安裝成功。post

用Package Control安裝插件的方法:

  1. 按下Ctrl+Shift+P調出命令面板
  2. 輸入install 調出 Install Package 選項並回車,而後在列表中選中要安裝的插件。如圖:

Pylinter.sublime-settings 配置了pylinter 插件。我使用下面的配置讓 Pyhton 在保存時自動規範,並對違反規範顯示圖標。ui

複製代碼
 1 {  2 // Configure pylint's behavior  3 "pylint_rc": "/Users/daniel/dev/pylintrc",  4  5 // Show different icons for errors, warnings, etc.  6 "use_icons": true,  7  8 // Automatically run Pylinter when saving a Python document  9 "run_on_save": true, 10 11 // Don't hide pylint messages when moving the cursor 12 "message_stay": true 13 }

複製代碼

 

SublimeCodeIntel 插件url

  智能提示插件,這個插件的智能提示功能很是強大,能夠自定義提示的內容庫,個人Python智能提示設置spa

複製代碼
 1     "Python": {  2 "python":"D:/Python27/python.exe",  3 "pythonExtraPaths":  4  [  5 "D:/Python27",  6 "D:/Python27/DLLs",  7 "D:/Python27/Lib",  8 "D:/Python27/Lib/lib-tk",  9 "D:/Python27/Lib/site-packages" 10  ] 11 }
複製代碼

 

Python PEP8 Autoformat 插件.net

 

這是用來按PEP8自動格式化代碼的。能夠在包管理器中安裝。快捷鍵 CTRL+SHIFT+R 自動格式化python代碼

 

經常使用配置

複製代碼
 1 {  2 "auto_complete": false,  3 "caret_style": "solid",  4 "ensure_newline_at_eof_on_save": true,  5 "find_selected_text": true,  6 "font_size": 11.0,  7 "highlight_modified_tabs": true,  8 "line_padding_bottom": 0,  9 "line_padding_top": 0, 10 "scroll_past_end": false, 11 "show_minimap": false, 12 "tab_size": 4, 13 "translate_tabs_to_spaces": true, 14 "trim_trailing_white_space_on_save": true, 15 "wide_caret": true, 16 "word_wrap": true, 17 }
複製代碼

 


 

SublimeREPL


一、調用ctrl+shift+p,輸入:sublimerepl選擇並安裝;(本機安裝時候竟然找不到這個sublimerepl,後來輸入install package才調出來)
二、而後tools --sublimeREPL--Python你會發現打開了一個python的shell窗口,顯然這個並非咱們想要的;
三、繼續往下走,選擇好咱們要執行的py文件,選擇Tools -> SublimeREPL -> Python -> RUN current file,這時候已經支持輸入了數據了;
以下圖所示:


四、爲了調試方便,咱們能夠把這個窗口放到右邊,先設置sublime的窗口顯示爲多層:

而後再調用發現:

這樣更方便調試用;
五、最後,因爲每次運行程序都要執行:Tools -> SublimeREPL -> Python -> RUN current file 菜單有點麻煩,因此如今能夠考慮給他建立個快捷鍵;
方法:perferences -- key bindings user 中粘貼以下代碼(快捷鍵我的喜歡F5):
[ {"keys":["f5"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}}
]

這樣之後你打開你要運行的Py程序,就能夠直接按照你設置的快捷鍵運行了;

3、後語
此插件不知道爲何,有時候運行會報錯,但有時候是好的,錯誤以下:
我的的解決辦法是,按幾下ctrl+b編譯下有時候會好。。。。不知道還有沒有根本的解決辦法;整體來講這個插件不是太好用。。。
 
 
可能有用的快捷鍵:
 
選中一個變量,ALT+F3能夠選中所有同名變量
相關文章
相關標籤/搜索