ubuntu sublime text3 python configuration sublime text3 python configuration

ubuntu sublime text3 python configuration

1. Installation sublime text 3
Installation process is very simple, enter in the terminal:
sudo add-apt-repository ppa: webupd8team / sublime-text-3 # 3 add sublime text warehouse
sudo apt-get update # update the software library
sudo apt-get install sublime-text-installer #安装Sublime Text 3
If you need to start the sublime, then enter the terminal in
subl
Note that if you need to uninstall, then enter the terminal in
sudo apt-get remove sublime-text-installer
 
2. Install Package Control
In order to use a large number of plug-ins to extend the functionality Sublime, you will need to install a plugin called the Package Control Manager - this thing you have to install it manually. But once you have installed the future, you can use the Package Control to install, remove or upgrade all ST3 plugin.
1]. Click https://packagecontrol.io/installation#st3 get the code for installation from Sublime Text 3 official. Click View> Show Console Open ST3 console. Just paste the code in the console, and then click Enter. The final restart ST3.
2]. Now you can install other plug-ins to open Package Control through the shortcut cmd + shift + P. Enter the install and then you can see on the screen appeared Package Control: Install Package, then click on the Enter your desired search plug-ins.
3] Other related commands are as follows:
List Packages displays all installed plug-ins
Remove Packages to remove a specified plug
Upgrade Package update a specific plug-in
Upgrade / Overwrite All Packages update all installed plug-ins
 
3. Install the plug anaconda
3.1 Introduction
Anaconda is the ultimate Python plugin. It adds a number of IDE similar functionality for ST3, for example:
Autocompletion automatically, this option is turned on by default, and offers a variety of configuration options.
Use Code linting support pep8 standard PyLint or PyFlakes. Because I personally use is another linting tools, so I will Anaconda.sublime-settings in the configuration file in Anaconda linting completely disabled. As follows: Sublime> Preferences> Package Settings> Anaconda> Settings - User: { "anaconda_linting": false}
McCabe code complexity checker lets you use the McCabe complexity checker in a particular file. If you are not familiar with the complexity of the software inspection tools, please be sure to link to the top of the browser.
Goto Definitions able to look at your entire project and display any variable, function, or class definition.
Find Usage able to quickly find a variable, a function or a class somewhere in a particular file is used.
Show Documentation: a function capable of displaying the descriptive string or class (of course, in the case where the character string is defined)
3.2. Installation
Now you can install other plug-ins to open Package Control through the shortcut cmd + shift + P. Enter the install and then you can see on the screen appeared Package Control: Install Package, then click on the Enter your desired search plug-ins (such as Anaconda)
Enter the installation interface, good installation and then enter the new Anaconda in the command line window and click on the first choices for installation. The document is displayed messages after the installation is complete.
After installing the plug-in Anaconda completed, will see the following options bar, indicating Anaconda installation was successful.
3.3. Configuration
Since Anaconda plug-in itself can not know the path to Python installed, you need to set the actual position of the main program of Python. Select Preferences-Package Settings-Anacoda-Settings-Default option to search for "python_interpreter" key,
And "python_interpreter": "Python" was changed to "python_interpreter": "/ usr / bin / python2.7"
Note: This "/usr/bin/python2.7" is my python path, everyone needs to be set according to their own computer, to find ways python path is entered in the terminal:
whereis python
That can be seen python path
选择Preferences-Package Settings-Anacoda-Settings-Users选项,键入以下json数据。保存,重启ST3即可。
{
"python_interpreter": "/usr/bin/python2.7",
"suppress_word_completions": true,
"suppress_explicit_completions": true,
"complete_parameters": true,
}
接下来,就会发现,ST3编写python代码时会有提示功能。




▶Terminal:打开一个命令窗口,用于各种命令操作
 
▶AutoPep8:python开发规范pep8
 
▶Anaconda:自动匹配关键字等实用功能,有效提高开发效率
 
▶SublimeREPL:直接运行当前文件,可以方便调试,与Terminal可以联合使用 至于具体可参考资料【4】


SideBarEnhancements

SideBarEnhancements 扩展了侧边栏中菜单选项的数量,从而提升你的工作效率。诸如”New file” 和 “Duplicate” 这样的选项对于 ST3 来说实在是太重要了, 我甚至觉得 ST3 本来就应该提供这些功能。而且仅凭 “Delete” 这一个功能就让这个插件值得下载。这个功能将你会在你删除文件的时候把它放入回收站。虽然这个功能乍一看没什么用,但是当你没有使用这样的功能而彻底删除了一个文件的时候,除非你用了版本管理软件,否则你将很难恢复这个文件。

现在就下载吧!

Anaconda

Anaconda 是一个终极 Python 插件。它为 ST3 增添了多项 IDE 类似的功能,例如:

  • Autocompletion 自动完成,该选项默认开启,同时提供多种配置选项
  • Code linting 使用支持 pep8 标准的 PyLint 或者 PyFlakes。因为我个人使用的是另外的 linting 工具,所以我会在 Anaconda 的配置文件 Anaconda.sublime-settings 中将 linting 完全禁用。操作如下: Sublime > Preferences > Package Settings > Anaconda > Settings – User: {"anaconda_linting": false}
  • McCabe code complexity checker 让你可以在特定的文件中使用 McCabe complexity checker. 如果你对软件复杂度检查工具不太熟悉的话,请务必先浏览上边的链接。
  • Goto Definitions 能够在你的整个工程中查找并且显示任意一个变量,函数,或者类的定义。
  • Find Usage 能够快速的查找某个变量,函数或者类在某个特定文件中的什么地方被使用了。
  • Show Documentation: 能够显示一个函数或者类的说明性字符串(当然,是在定义了字符串的情况下)

你可以在这里,或者通过 ST3 的 Package Settings: Sublime Text > Preferences > Package Settings > Anaconda > README 来查看所有这些特性。

SublimeCodeIntel 是另外一个非常流行的插件,它的许多特性与 Anaconda 类似。我建议同时也试试它。

Djaneiro

Djaneiro 支持 Django 模版和关键字高亮以及许多实用的代码片(snippets)功能。其中的 snippets 绝对是省时神器。你可以通过很少几个关键字就能创建许多常见的 Django 代码块比如 templates,models,forms,以及 views。请查看官方文档获取 snippets 列表。

我个人非常喜欢的以下两个用于创建 template 的代码片:输入 var 就可以新建 {{ }},而输入 tag 就能新建 {% %}

requirementstxt

Requirementstxt 可以为你的 requirements.txt 文件提供自动补全,语法高亮以及版本管理功能。

SublimeLinter

SublimeLinter 是 ST3 的一个代码静态检查工具框架(linter)。这个插件本身来说并不包含任何的一个 linter,但是你可以通过在 Package Control 中输入 SublimeLinter-[linter_name] 的方式来安装一个 linter。你可以点击这里查看官方的 linter。同时你还可以在 Package Control 中查看到许多的第三方 linter。请点击这里查看安装说明。

对于 Python 的代码静态检查器,我建议使用 SublimeLinter-pyflakes 和 SublimeLinter-pep8

与此同时,我也会使用 SublimeLinter-jshintSublimeLinter-pyyamlSublimeLinter-csslintSublimeLinter-html-tidy,以及SublimeLinter-json

以上大多数的 linter 都需要先安装一些依赖库才能使用,所以在安装前请务必阅读他们的安装说明。

你可以通过修改用户自定义的 SublimeLinter.sublime-settings 文件来对你的每个 linter 个性化:Sublime Text > Preferences > Package Settings > SublimeLinter > Settings – User. 例如我通过以下代码来忽略 pep8 中的错误和警告:

GitGutter

GitGutter 让 ST3 能在左边栏的位置显示一个小图标,用以表示在最后一次提交以后,代码是否有追加,修改或者删除。

如果你想让该插件支持分布式的版本管理软件(Git,SVN,Bazaar 和 Mercurial)。请查看 Modific

FTPSync

FTPSync 能够将你的项目和远程文件进行同步。你只需要打开文件便可以下载更新(如果你的远端文件比本地更加新的话),而且如果你对本地文件做出了修改可以立即同步到远程服务器。这是非常棒的同步本地文件和远程文件的方法。你可以通过以下的方法来添加你的远程服务器:Sublime Text > Preferences > Package Settings > FTPSync > Setup FTPSync.

Sample settings:

我个人喜欢把密码设为 null 因为我不想让我的密码出现在配置文件中。这样 FTPSync 会在我每次保存完文件后要求我输入密码。

AdvancedNewFile

AdvancedNewFile 可以让你在 ST3 中使用简单的几个快捷键便创建一个新的文件夹或者一个新的文件:

你只需要通过几个快捷键便可以打开 AdvancedNewFile 的输入框。然后输入路径和文件名。当你按下回车键后,文件便被创建了。除此之外,如果目标文件夹并不存在的话,该文件夹将会被自动建立。在默认情况下,你创建的文件的路径将会显示在状态栏中。

请查看 Github 上的这篇文档来获取更为详细的使用说明。特别建议请详细阅读TAB自动补全(Tab Completion)以及预定义别名(Predefined Aliases)部分。

我把“cmd+n”设置为了通过 AdvancedNewFile 创建新文件的快捷方式。该快捷键可以通过修改 Key Bindings – User file 来实现 Sublime Text > Preferences > Package Settings > AdvancedNewFile > Key Bindings – User:

你也可以更改默认打开的文件夹路径:Sublime Text > Preferences > Package Settings > AdvancedNewFile > Settings – User

这样我创建新文件的时候,/Users/michaelherman/Documents/repos将会自动被添加到路径最前方,因为99%的情况下我都会把我的脚本放在这个路径下。

Emmet

Emmet,以前叫做 Zen Coding,让你可以通过简单的缩写来创建 HTML 或者 CSS 的代码块。

例如,你只需要输入感叹号!,然后按下 tab 键,便可以在一个 HTML 文件中创建一段带有几个基本标签的 HTML5 文档类型的代码:

请查看官方文档或者速查手册获取更多信息。

Markdown Preview

Markdown Preview 可以用来预览和编译 markdown 文件。

你可以打开 Package Manager 然后输入 Markdown Preview 来查看可用的命令:

  • Markdown Preview: Python Mrakdown: 在浏览器中预览
  • Markdown Preview: Python Mrakdown: 导出 HTML 文件
  • Markdown Preview: Python Mrakdown: 拷贝到剪贴板
  • Markdown Preview: Github风格Markdown: 在浏览器中预览
  • Markdown Preview: Github风格Markdown: 导出 HTML 文件
  • Markdown Preview: Github风格Markdown: 拷贝到剪贴板
  • Markdown Preview: 打开Markdown速查手册

一旦你完成转换,你之后的所有保存都会立即反映到转换的文件中。

快捷键

  1. 跳转到任意内容 (“cmd+p”) 用来快速查找和打开文件。你仅仅只需要工程中文件的一部分路径或者文件名你就可以很容易的打开这个文件。这在一个大型的 Django 工程中显得非常方便。
  2. 跳转到指定行 (“ctrl+g”) 让你在当前文件中跳转到指定行数。
  3. 跳转到标志 (“cmd+r”) 可以列出当前文件中所有的函数或者类,让你更方便查找。你可以通过输入关键字来查找你所需要的函数或者类。
  4. 跳转到行首 (cmd+left-arrow-key) 与 跳转到行尾 (cmd+right-arrow-key)
  5. 删除当前行(ctrl+shift+k)
  6. 多重编辑 是我迄今为止最喜欢的快捷键
  7. 块编辑 (option+left-mouse-click) 用于选择一整块的内容。通常在整理 CSV 文件的时候用于删除空白内容。

Guess you like

Origin www.cnblogs.com/HHHAI/p/11128332.html