zoukankan      html  css  js  c++  java
  • Sublime Text 3 python 配置

    Sublime Text 3 python 配置

    Package Control 安装方法

      1.通过快捷键 ctrl+` 或者 View > Show Console 打开控制台,然后粘贴相应的 Python 安装代码;

      2.Sublime Text 3 安装代码并回车:

    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())

      3.重启Sublime Text 3;

      4.如果在Perferences->package settings中看到package control这一项,则安装成功。

    用Package Control安装插件的方法:

    1. 按下Ctrl+Shift+P调出命令面板
    2. 输入install 调出 Install Package 选项并回车,然后在列表中选中要安装的插件。如图:

    Pylinter.sublime-settings 配置了pylinter 插件。我使用下面的配置让 Pyhton 在保存时自动规范,并对违反规范显示图标。

    复制代码
     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 插件

      智能提示插件,这个插件的智能提示功能非常强大,可以自定义提示的内容库,我的Python智能提示设置

    复制代码
     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 插件

    这是用来按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


    1、调用ctrl+shift+p,输入:sublimerepl选择并安装;(本机安装时候居然找不到这个sublimerepl,后来输入install package才调出来)
    2、然后tools --sublimeREPL--Python你会发现打开了一个python的shell窗口,显然这个并不是我们想要的;
    3、继续往下走,选择好我们要执行的py文件,选择Tools -> SublimeREPL -> Python -> RUN current file,这时候已经支持输入了数据了;
    如下图所示:


    4、为了调试方便,我们可以把这个窗口放到右边,先设置sublime的窗口显示为多层:

    然后再调用发现:

    这样更方便调试用;
    5、最后,由于每次运行程序都要执行: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程序,就可以直接按照你设置的快捷键运行了;

    三、后语
    此插件不知道为什么,有时候运行会报错,但有时候是好的,错误如下:
    个人的解决办法是,按几下ctrl+b编译下有时候会好。。。。不知道还有没有根本的解决办法;总体来说这个插件不是太好用。。。
     
     
    可能有用的快捷键:
     
    选中一个变量,ALT+F3可以选中全部同名变量
  • 相关阅读:
    存储过程
    输入http://localhost/,apache出现You don't have permission to access/on this server.的提示,如何解决?
    搭建内网的NTP时间服务器
    cobbler自动化安装系统
    Linux三剑客之awk最佳实践
    ansible学习笔记
    2021.05.07 多线程之可重入锁
    2021.05.08 easyExcel简单读写
    2021.05.03 Java常用文件路径
    2021.05.04 二维码生成与解析
  • 原文地址:https://www.cnblogs.com/sunchao1984/p/5132002.html
Copyright © 2011-2022 走看看