sublime配置python环境变量_Sublime Python环境配置
文章主要說明了能讓Python的編程者使用更方便的一些設置和調整。
Sublime Text簡介
Sublime Text是一個很棒的編輯器,支持跨平臺,有著強大的插件子系統。對于Python開發,有不少插件可以讓你開發起來更流暢、更有樂趣。
我現在仍然在不同的項目之間切換編輯器。不過我發現對應Python開發,Sublime在輕量級的編輯器和全功能的IDE之間有著很好的平衡。
安裝插件
正如之前提到的, Sublime 有一個非常豐富的插件系統。而我當前使用的插件如下:
Package Control?在 Sublime 里直接安裝附加插件的包管理器。
ChineseLocalizations?Sublime系統語言插件,改為中文菜單
ConvertToUTF8 處理中文亂碼問題
SublimeCodeIntel?為部分語言增強自動完成功能,包括了 Python 。這個插件同時也可以讓你跳轉到符號定義的地方,通過按住 alt 并點擊符號。非常方便。
SideBarEnhancements?這個插件提供了側邊欄附加的上下文菜單選項,例如"New file","New Floder"等。這些本應當默認就該有的,卻沒有。
SideBarHider
SublimeREPL?允許你在編輯界面直接運行 Python 解釋器。我傾向于在單獨的終端窗口用?bpython?來運行,但有時 SublimeREPL 是很有幫助的。
SublimeTmpl Sublime模板
ctags跨文件跳轉,跳轉到指定函數聲明的地方(ctrl+alt+左鍵)。
window 下載 ctags.exe(prdownloads.sourceforge.net/ctags/ctags58.zip,ctags.exe文件放在一個環境變量能訪問到的地方),然后在打開的工程目錄上運行ctags?-R?-f?.tags生成
ubuntu下安裝運行命令:sudo apt-get install exuberant-ctags
在CTags.sublime-setting--User中添加路徑:{"command": "C:\\Windows\\System32\\ctags.exe",}
BracketHighlighter該插件提供配對標簽,或大括號或字符引號的配對高亮顯示,算是對系統高亮的加強吧
Tomorrow Color Schemes?Color schemes?決定了編輯器界面語法高亮的字體顏色。這是一個非常酷的暗黑系樣式。
Theme - Soda SolarizedDark?Themes?影響 Sublime 界面元素的顏色和風格。這個非常適合 Tomorrow Night 的配色方案。
All Autocomplete?Sublime 默認的自動完成只關注當前文件的單詞。這個插件擴展了其自動完成的單詞列表到所有打開的文件。
TortoiseSVN生成后右鍵點擊文件或文件夾(這個要錢,如果是windows的話用TorstoiseSVN,這個要先預裝TorstoiseSVN)
OmniMarkupPreviewer?支持將標記語言(Markdown僅是其中一種)渲染為 HTML 并在瀏覽器上實時預覽,同時支持導出 HTML 源碼文件
使用Anaconda進行代碼自動校驗、修正(按PEP8)
配置文件
Sublime Text 的一個優點就是它的所有配置都是簡單的基于 JSON 的配置文件。這使得你可以很容易的將配置轉到另一個系統中。我也見過一些人使用 Dropbox 自動同步他們所有電腦上的配置。
Preferences.sublime-settings?配置了 Sublimede 的顯示和行為.你可以在sublime 中通過?Preferences > Settings — User?打開并編輯此文件。我使用如下配置:
{
// Colors
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"theme": "Soda SolarizedDark.sublime-theme",
// Cursor style - no blinking and slightly wider than default
"caret_style": "solid",
"wide_caret": true,
// Font
"font_face": "Ubuntu Mono",
"font_size": 16.0,
"font_options":
[
"subpixel_antialias",
"no_bold"
],
"line_padding_bottom": 0,
"line_padding_top": 0,
// 折疊,展開選項
"fold_buttons": true,
"fade_fold_buttons": false,
"highlight_line": true,
"auto_complete": true,
"show_minimap": true,
// Word wrapping - follow PEP 8 recommendations
"rulers": [ 72, 79 ],
"word_wrap": false,
"wrap_width": 80,
// Editor view look-and-feel
"draw_white_space": "all",
// Editor behavior
"scroll_past_end": false,
"highlight_modified_tabs": true,
"find_selected_text": true,
// Whitespace - no tabs, trimming, end files with \n
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
// 不顯示的包、文件夾、文件
"ignored_packages":
[
"Vintage", "Markdown"
],
"folder_exclude_patterns":
[
".git",
"__pycache__",
"env",
"env3",
".svn"
],
"file_exclude_patterns":
[
".DS_Store",
"*.pid",
"*.pyc",
".tags",
".tags_sorted_by_file",
"*.exe",
".svn-base"
],
}
Anaconda.sublime-settings配置如下:
{
// python運行地址
"python_interpreter": "C:/Python27/python.exe",
// AutoComplete設置
"suppress_word_completions":true,
"suppress_explicit_completions":true,
"complete_parameters":true,
// AutoFormatting
"auto_formatting": true,
"auto_formatting_timeout": 2,
"autoformat_ignore":
[
"E309",
"E501",
],
// 是否啟用linter
"anaconda_linting": false,
"anaconda_linting_behaviour": "load-save",
// 頁面報錯
"anaconda_gutter_theme": "simple",
"anaconda_linter_mark_style": "outline",
"anaconda_gutter_marks": true,
"anaconda_linter_underlines": true,
"anaconda_linter_phantoms": true,
"use_pylint": false,
"pylint_ignore":
[
"C0111",
],
"pep8": true,
"pep8_ignore":
[
"E309",
"E501",
"C0111"
],
}
按鍵綁定
Sublime 的按鍵綁定也是全部可配置的基于JSON的 sublime-keymap 配置文件。我修改了一些默認配置以更好的配合我的 TextMate / IntelliJ 肌肉記憶。你可以完全不修改。如果你想,修改很簡單,并可以跨平臺使用。我使用如下的綁定:
[
// Rebind "go to file" to cmd+shift+O
{ "keys": ["super+shift+o"], "command": "show_overlay", "args": {
"overlay": "goto",
"show_files": true
}},
// Rebind swap line up/down to cmd+shift+up/down
{ "keys": ["super+shift+up"], "command": "swap_line_up" },
{ "keys": ["super+shift+down"], "command": "swap_line_down" },
// Delete a line with cmd+delete
{ "keys": ["super+backspace"], "command": "run_macro_file", "args": {
"file": "Packages/Default/Delete Line.sublime-macro"
}},
// Reindent selection with cmd+alt+L
{ "keys": ["super+alt+l"], "command": "reindent"}
]
命令行工具
同 TextMate 的 mate 類似,Sublime Text 包含了一個命令行工具,允許你通過 shell 打開編輯器。工具名為 sublis,默認不可用。要使之生效,在任一 shell 中運行下面:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
更多靈感
我希望這篇安裝指南能夠幫到你。如果你有任何建議或意見,敬請 Twitter 我一行或給我發郵件。另外,感謝下面的作者及其關于配置 sublime 的作品。它們啟發了我很多:
總結
以上是生活随笔為你收集整理的sublime配置python环境变量_Sublime Python环境配置的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: html前端论文参考文献,web前端论文
 - 下一篇: 碎片化学习不是学习碎片,看这篇了解碎片化