在sublime text怎么运行3中编写的.py怎么运行

加油努力,
奋起直追,不埋怨,不抱怨,加油
原文地址:/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/
原文标题:Setting Up Sublime Text 3 for Full Stack Python Development
翻译:打造基于sublime text 3的全能Python开发环境
(ST3) is lightweight, cross-platform code editor known for its speed, ease of use, and strong community support. It&s an incredible editor right out of the box, but the real power comes from the ability to enhance its functionality using Package Control and creating custom settings.
In this article, we&ll look at how to setup Sublime Text for full stack Python development (from the front to back), enhance the basic functionality with custom themes and packages, and use many of the commands, features, and keyword shortcuts that make ST3 so powerful.
ST3是一个以运行速度,易用性和强大社区支持而著称的轻量级跨平台代码编辑器。它是一个难以置信的开箱即用的编辑器,但是通过包管理器和自定义设置来增强本身的功能其实st3强大力量的来源。
本文将介绍如何为全方位的Python开发(从前段到后端)配置ST3,通过自定义主题和扩展报来增强基本功能,大量命令,特性和基于关键词快捷键的使用让st3变得十分强大.
This tutorial assumes you&re using a Mac and are comfortable with the terminal. If you&re using Windows or Linux, many of the commands will vary, but you should be able to use Google to find the answers quickly given the info in this tutorial.
本教程假设你用的是Mac操作系统并且能够熟练的使用命令行终端.如果你用的是windows或者Linux操作系统,有些命令可能会不一样,不过你应该可以通过google来找到如何在你自己系统中使用本教程提到的命令.
Before we start, let&s address what I mean exactly by &full stack&.
In today&s world of HTML5 and mobile development, Javascript is literally everywhere. EVERYWHERE. Python coupled with a framework such as Django or Flask is not enough. To really develop a website from end-to-end, you must be familiar with Javascript (and the various Javascript frameworks), REST APIs, responsive design, and of course HTML and CSS, among others. And let&s face it: Like any craftsman, in order to be the best programmer you can be, your tools must be sharp. Your development environment must be setup for full stack development & which is exactly what we are going to do right now&
在开始本教程之前,让我们来明确一下我所指的全方位(full stack)是什么意思.在当今的HTML5和移动设备开发中,javascript被广泛使用.everywhere!python结合诸如Django和Flask之类的框架是不能满足需求的.为了开发一个端到端的网站,你必须熟悉javascript及其大量的js框架,rest apis,响应式设计,html&css和其他.为了成为最好的程序员,工欲善其事必先利其器!你必须把你的开发环境配置成适应全方位开发,这就是我们接下来将要做的
Let&s start by looking at a few of the default features of Sublime Text 3&
Split Layouts allow you to arrange your files in various split-screens. This is useful for test driven development (Python code on one screen, test scripts on another) or when working on the front end (HTML on one screen, CSS and/or Javascript on another).
首先我们来看sublime text 3提供的一系列默认的特性
分割布局允许你用多种屏幕分割方式来组织代码.在测试驱动的开发中特别用用(python代码在一个屏幕,测试脚本在另外一个)或者前段开发(html在一个屏幕,css和js在另一个)特别游泳.
provides you with vi commands for use within ST3.
Chrome-like Tabs make navigating and editing several files much simpler.
Automatic loading of the last session re-opens all files and folders you had open when you closed the editor the last time. I leave ST3 open all the time, with various projects open & so if I reset the computer, it opens the files and folders right back up.
Code Snippets increase your productivity by giving you the ability to create common pieces of code with a single keyword. There are a number of default snippets. For example, open a new file and type in &lorem& then press tab. You should get a paragraph of lorem ipsum text. Also, if you type &defs& then press tab in a Python file it will setup a generic function.
You can also create your own snippets: Tools & New Snippet. Refer to the
for help, and also check out some of my snippets .
Vintage模式允许你在st3中使用vi命令
Chrome-like标签也让多文件导航和编辑变得更加容易
自动加载上一次会话,自动打开你上次关闭st3之前打开的文件和文件夹.作者st3常开,并且同时打开多个项目,如果重启电脑,立刻打开备份的文件和文件夹
代码片段让你能够通过一个关键词来创建代码段来提高你的效率.有很多默认的代码片段.例如,新建一个文件,输入lorem,按tab键,你将会得到一大段文字.如果你在python文件中输入defs并且敲tab会的到一个通用的函数体.
Customizing Sublime Text 3
After downloading ST3 &
Install the subl command line tool
Like the mate command for TextMate, Sublime Text includes a command line tool called
that allows you to open one file, or an entire directory of files and folders, from the terminal.
To enable this command, create a symbolic link to the subl binary:
下载st3之后
安装subl命令行工具
就像TextMate的mate命令,sublime text包含了一个叫做让你能够从终端打开一个文件或者一系列文件文件夹的命令行工具
为了使用这个命令,建立一个到subl库的符号链接
$ sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl
&Ensure that the link works by opening Sublime:
通过打开sublime来确认链接可用
&If that didn&t work, you probably need to add /bin to your Path:
如果subl不起作用,你可能需要把/bin添加到你的环境变量
$ echo "export PATH=~/bin:$PATH" && ~/.profile
&现在你可用下面的命令打开文件和目录:
# open the current directory
# open a directory called tests
$ subl ~/Documents/test
# open a file called text.txt
$ subl test.txt
译注:我用的ubutnu 15.04安装st3的deb包,命令行下直接就可用使用subl,所以这一步可用省略
$ subl hello.py
# 直接就可以在sublime里打开,不用设置$ subl "hello world" # 如果路径中有空格,路径必须加引号$ subl --help # 可用查看所有的命令
Install Package Control
To begin taking advantage of the various
for extending Sublime&s functionality, you need to install the package manager called Package Control & which you must install manually. Once installed, you can use Package Control to install/remove/upgrade all other ST3 packages.
To install, copy the Python code for Sublime Text 3 found . Click View & Show Console to open the ST3 console. Paste the code into the console. Press enter. Reboot ST3.
You can now install packages by using the keyboard shortcut cmd+shift+P. Start typing install until Package Control: Install Package appears. Press enter and search for available packages.
Some other relevant commands are:
List Packages shows all your installed packages
Remove Packages removes a specific package
Upgrade Package upgrades a specific package
Upgrade/Overwrite All Packages upgrades all your installed packages
Check out the official
to view more commands.
&安装包管理器为了利用各种扩展sublime功能的包,你需要手动安装一个叫做Package Control的包管理器.安装之后,你可以通过它来安装/卸载/升级所有st3包(插件).
为了安装插件你必须复制这里为st3设计的python代码.单击视图&显示控制台来打开st3控制台,把代码粘贴到控制带,回车并且重启st3
你现在可用通过ctrl+shift+p来安装插件.按快捷键后输入instal,直到Package Control: Install Package出现.敲回车并且搜索可用的插件.
一些其他的命令包括
列出你已经安装的插件
删除一个特定的插件
升级特定的插件
升级/覆盖所有包 升级你所有的插件
查看官方文档获取更多命令.
Create a Custom Settings File
You can fully configure Sublime Text using JSON-based settings files, making it easy to transfer, or synchronize, your customized settings to another system. First, we need to create our customized settings. It&s best to create a base file for all environments as well as language-specific settings files.
To set up a base file click Sublime Text & Preferences & Settings & User. Add an empty JSON object to the file and add your settings like so:
新建自定义配置文件
你可以通过json格式配置文件自由的配置sublime text,采用json格式使得配置文件易于传输,或者同步你的配置到其他系统.首先我们需要创建自己的自定义设置.建议分别设置针对所有的环境的基本配置文件和针对特定语言的配置文件.
通过sublime text&选项&配置-用户来创建一个基本配置.在文件中添加一个空的json对象,并且添加配置
// base settings
"auto_complete": false,
"sublimelinter": false,
"tab_size": 2,
"word_wrap": true
特定语言的配置,Sublime Text & Preferences & Settings & More & Syntax Specific & Use,用语言名.sulime-settings来保存,比如针对python的配置文件就是Python.sublime-settings
你可以对st做任意配置,但是我强力推荐你从配置基本配置和针对python的配置开始,接下来你将会看到改变
可选:你可以用Dropbox来同步你所有的配置,把文件上传到Dropbox并且在所有的电脑上加载并同步sublime环境.
一个很好的sublime配置参考.
ST3 also gives you the option to change the overall theme to better suit your personality. Design your own. Or, if you&re not artistically inclined, you can download one of the various custom
designed by the Sublime community through Package Control. Check out
to preview themes before installing them.
The ever popular
and the minimal
are two of my personal favorites.
After installing a theme, make sure to update your base settings, Sublime Text & Preferences & Settings & User:
除了打包的主题,我也用下面这些插件来增加速我的工作流.
SideBarEnhancements侧边栏增强
extends the number of menu options in the sidebar, speeding up your overall workflow. Options such as &New file& and &Duplicate& are essential and should be part of ST3 out of the box. The &Delete& option alone makes it worth downloading. This feature simply sends files to the Trash, which may seem trivial but if you delete a file without it, it&s very difficult to recover unless you&re using a version control system.
这个插件扩展了侧边栏册单的数量,加速你算不的工作流.比如新建和复制是st3自带的基本选项,而"删除"选项让这个插件值得下载.这个功能把文件放到回收站看起来不是很重要的功能,但是你不用这个选项删除文件,除非你使用了版本控制系统否则你很难恢复文件.
Anaconda是一个旗舰版的Python插件,给st3添加了一系列类似IDE的功能,如:
Autocompletion works by default, but there are a number of configuration .默认自动完成,并且有一些配置选项
uses either PyLint or PyFlakes with pep8. I personally use a different linting package, as I will explain shortly, so I disable linting altogether within the user-defined Anaconda settings file, Anaconda.sublime-settings, via the file menu: Sublime & Preferences & Package Settings & Anaconda & Settings & User: {"anaconda_linting": false} 代码检查,用pylint或者pyflakes及pep8,作者使用不同的代码检查插件,所以作者简单的通过Anaconda用户配置文件来禁用Anaconda插件自带的代码检查功能
McCabe code complexity checker runs the
tool within a specific file. If you&re unfamiliar with a complexity checker, be sure to visit the link above.代码复杂度检测
Goto Definitions finds and displays the definition of any variable, function, or class throughout your entire project.查找并显示你工程中任何变量,函数和类.
Find Usage quickly searches where a variable, function, or class has been used in a specific file.特定文件中已经使用过的变量函数和类.
Show Documentation: shows the Docstring for functions or classes (if defined, of course).如果定义了文档,显示文档.
You can view all of the features , or within the README file in ST3&s Package Settings: Sublime Text & Preferences & Package Settings & Anaconda & README.点击链接查看所有功能,或者查看readme文件.
is another popular package, which has many of the same features as Anaconda. I suggest testing them both out.
这个插件是另外一个很受欢迎的插件,有很多和Anaconda类似的功能,建议你们都试用一下.
supports Django templating and keyword highlighting and provides useful code snippets (tab completions) for Sublime Text. The snippet system is an incredible timesaver. You can create common Django blocks with only a few keystrokes for templates, models, forms, and views. Check out the official
to see a list of snippets.
My personal favorites are for templating: var creates {{ }} and tag creates {% %}
requirementstxt
provides autocompletion and syntax highlight-lighting as well as a nice version management system for your requirements.txt files.
SublimeLinter
相关阅读:/a/9188
is a framework for ST3 linters. The package itself does not includ those must be installed separately via Package Control using the SublimeLinter-[linter_name] naming syntax. You can view official linters . There are also a number of third party linters, which can be viewed in Package Control. Check out the installation instructions .
SublimeLinter是一个ST3代码检查框架.插件本身不包含任何检查器.必须通过插件管理器用SublimeLinter-[linter_name]指定语法.点击链接查看所有官方检查器.你也可以试用第三方检查器,在插件管理器力可用查看.点击链接查看安装指导
For Python linting, I recommend using
对于Python代码检查,推荐SublimeLinter-pyflakes和SublimeLinter-pep8
I also use , , , , and .
Most of these linters have dependencies associated with them, so please read the installation instructions before installing.
You can customize each linter in the user-defined SublimeLinter.sublime-settings file: Sublime Text & Preferences & Package Settings & SublimeLinter & Settings & User. For example, I ignore the following pep8 errors and warnings:自定义错误的方法
"@disable": false,
"args": [],
"excludes": [],
"ignore": "E501,C,W,E,C,R,C,W,E,C0111",
"max-line-length": 100,
"select": ""
shows little icons in ST3&s gutter area that indicate whether a line has been inserted, modified, or deleted since the last commit.GitGutter 是一个兼容Sublime Text 2 或者Sublime Text 3 的插件,它可以在行数的前面显示那一行是被增加,修改还是删除。显示每行变化的插件.
, previously known as Zen Coding, uses simple abbreviations to generate HTML or CSS code snippets.
For example, if you type a bang, !, then press tab in an HTML file ,the HTML5 doctype and a few basic tags are generated:
&!doctype html&
&html lang="en"&
&meta charset="UTF-8"&
&title&Document&/title&
Check out the official
as well as this handy
for more info.
阅读(...) 评论()supermanse 的BLOG
用户名:supermanse
文章数:149
访问量:136883
注册日期:
阅读量:5863
阅读量:12276
阅读量:317860
阅读量:1030110
51CTO推荐博文
最近,当我主要使用Python开发环境编辑的时候,我开始越来越多地用到Sublinme Text 2.这篇文章主要说明了能让Python的编程者使用更方便的一些设置和调整。 650) this.width=650;" alt="设置 Sublime Text 的 Python 开发环境" src="http://static./lib/uploadImg/_774.png" height="286" width="700" />为何选择Sublime Text? 最近几周我开始越来越多的使用 。当我将它安装好之后,感觉非常不错。它确实非常快,自动定期的更新,以及更棒的是完全支持跨平台。对我来说,它最终胜过TextMate的地方是Sublime强大的插件子系统。对于Python开发,有不少插件可以让你开发起来更流畅、更有乐趣。 我现在仍然在不同的项目之间切换编辑器。不过我发现对应Python开发,Sublime在轻量级的编辑器和全功能的IDE之间有着很好的平衡。 字体的选择
是非常非常不错的字体。前些天我刚从
切换过来,这绝对不让人后悔。 在我的15寸的MacBook上,Ubuntu Mono的16号字非常适合。1680 × 1050的分辨率对于一个边栏加两个编辑器窗口(自动调整到80个字符宽)刚好合适。 如果你打算认真的挑选一下字体,
写的不错。它包含了大部分流行的编程方面的字体的截图及下载链接。 安装插件 正如之前提到的, Sublime 有一个非常丰富的插件系统。而我当前使用的插件如下:
在 Sublime 里直接安装附加插件的包管理器。这是唯一一个你必须手动安装的插件。这边列出的其他所有插件都可以通过 Package Control 来安装。也可以通过它来更新已安装过的插件。简单得想做是 Sublime packages 的 apt-get 就行了。Package for sublime text 2安装步骤: & & & 通过ctrl+` shortcut or the View & Show Console & 打开Sublime Text console.粘贴下列行:import urllib2,os, h = 'e96f11eeadd761d777e9d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else N urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else N print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')Color schemes 决定了编辑器界面语法高亮的字体颜色。这是一个非常酷的暗黑系样式。 Themes 影响 Sublime 界面元素的颜色和风格。这个非常适合 Tomorrow Night 的配色方案。
这个插件提供了侧边栏附加的上下文菜单选项,例如"New file","New Floder"等。这些本应当默认就该有的,却没有。
Sublime 默认的自动完成只关注当前文件的单词。这个插件扩展了其自动完成的单词列表到所有打开的文件。
为部分语言增强自动完成功能,包括了 Python 。这个插件同时也可以让你跳转到符号定义的地方,通过按住 alt 并点击符号。非常方便。
允许你在编辑界面直接运行 Python 解释器。我倾向于在单独的终端窗口用
来运行,但有时 SublimeREPL 是很有帮助的。
在编辑器的凹槽区,依照 Git ,增加小图标来标识一行是否被插入、修改或删除。在 GitGutter 的 readme 中有说明如何更改颜色图标来更新你的配色方案文件。
这个插件提供了目前我所见到的最好的
编辑器整合。它自动检查 .py 文件,无论其何时被保存,并且会直接在编辑界面显示 pylint 违规。它还有一个快捷方式来禁用局部的 pylint 检查,通过插入一个 #pylint: 禁用注释。这个插件对于我确实非常有用。 配置文件 Sublime Text 的一个优点就是它的所有配置都是简单的基于 JSON 的。这使得你可以很容易的将配置转到另一个系统中。我也见过一些人使用 Dropbox 自动同步他们所有电脑上的配置。 Preferences.sublime-settings 配置了 Sublimede 的显示和行为.你可以在sublime 中通过 Preferences & Settings ― User 打开并编辑此文件。我使用如下配置: 01{0203"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",04"theme": "Soda Dark.sublime-theme",050607"font_face": "Ubuntu Mono",08"font_size": 16.0,09"font_options": ["subpixel_antialias", "no_bold"],10"line_padding_bottom": 0,11"line_padding_top": 0,121314"caret_style": "solid",15"wide_caret": true,161718"draw_white_space": "all",19"fold_buttons": false,20"highlight_line": true,21"auto_complete": false,22"show_minimap": false,232425"scroll_past_end": false,26"highlight_modified_tabs": true,27"find_selected_text": true,282930"rulers": [ 72, 79 ],31"word_wrap": true,32"wrap_width": 80,333435"tab_size": 4,36"translate_tabs_to_spaces": true,37"trim_trailing_white_space_on_save": true,38"ensure_newline_at_eof_on_save": true,394041"file_exclude_patterns":42[43".DS_Store",44"*.pid",45"*.pyc"46],47"folder_exclude_patterns":48[49".git",50"__pycache__",51"env",52"env3"53]54}Pylinter.sublime-settings配置了pylinter 插件。我使用下面的配置让 Pyhton 在保存时自动规范,并对违反规范显示图标。 01{0203"pylint_rc": "/Users/daniel/dev/pylintrc",040506"use_icons": true,070809"run_on_save": true,101112"message_stay": true13}按键绑定 Sublime 的按键绑定也是全部可配置的基于JSON的 sublime-keymap 配置文件。我修改了一些默认配置以更好的配合我的 TextMate / IntelliJ 肌肉记忆。你可以完全不修改。如果你想,修改很简单,并可以跨平台使用。我使用如下的绑定: 01[0203{ "keys": ["super+shift+o"], "command": "show_overlay", "args": {04"overlay": "goto",05"show_files": true06}},070809{ "keys": ["super+shift+up"], "command": "swap_line_up"},10{ "keys": ["super+shift+down"], "command": "swap_line_down"},111213{ "keys": ["super+backspace"], "command": "run_macro_file", "args": {14"file": "Packages/Default/Delete Line.sublime-macro"15}},161718{ "keys": ["super+alt+l"], "command": "reindent"}19]命令行工具 同 TextMate 的 mate 类似,Sublime Text 包含了一个命令行工具,允许你通过 shell 打开编辑器。工具名为 sublis,默认不可用。要使之生效,在任一 shell 中运行下面: 1ln-s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl要将 Sublime 作为 git 互动命令的默认编辑器使用――举例,撰写提交信息――只需添加下面一行到你的 ~/.profile 文件: 1exportGIT_EDITOR="subl --wait --new-window"SublimeREPL添加快捷键转自
SublimeREPL安装之后没有快捷键,每次运行程序必须用鼠标去点工具栏,有些不爽,所以需要给SublimeREPL添加快捷键。可以看到所有Python方法的名称及id,根据此可以自定义用户快捷键,在偏好--键绑定C用户中输入:[{"keys":["f5"],"caption":"SublimeREPL: Python - RUN current file","command":"run_existing_window_command", "args":{"id":"repl_python_run","file": "config/Python/Main.sublime-menu"}}]本文仅定义了Python- RUN current file的快捷键,我在这里使用的是F5,可以根据自己的需要进行灵活的调整。
了这篇文章
类别:┆阅读(0)┆评论(0)怎么在sublime text 3中编译运行java文件?-中国学网-中国IT综合门户网站-提供健康,养生,留学,移民,创业,汽车等信息
> 信息中心 >
怎么在sublime text 3中编译运行java文件?
来源:互联网 发表时间: 15:45:08 责任编辑:鲁晓倩字体:
为了帮助网友解决“怎么在sublime text 3中编译运行java文件?”相关的问题,中国学网通过互联网对“怎么在sublime text 3中编译运行java文件?”相关的解决方案进行了整理,用户详细问题包括:RT,我想知道:怎么在sublime text 3中编译运行java文件?,具体解决方案如下:解决方案1:;;encoding&;&working_dir&;encoding&quot,新建文件JavaC;encoding&,&quot: true.,依次点击P 下面的命令需要按Ctrl+Shift+b来运行&quot,依次点击Preference,Ctrl+shift+b运行.bat文件,&/执行完上面的命令就结束&#47.if exist %~n1,&: &quot,&;&quot,&quot.sublime-build, &;:1;-d&quot, /$file&#92,新建文件JavaC,在打开的窗口中双击User文件夹,用记事本打开;:([0-9]*); /GBK&runJava,&^(。 &#47: [&&quot..bat &#92。方法二,复制粘贴如下代码并保存;source.class)javac -encoding UTF-8 %~nx1if exist %~n1: &quot.*;-encoding&quot.class (del %~n1,用记事本打开;&#47:@echo offcd %~dp1echo Compiling %~nx1; ;?);;cmd&cmd&;;&#47, &quot,&&#47,&selector&&#47.class (echo ------Output------java %~n1)3?([0-9]*)&;;;$file&quot.: &quot,粘贴下面的代码并保存关闭.;. 相当于输入一个回车 &#47.;selector&],&quot:.在JDK的bin目录下新建runJshell& } ]}ctrl+B编译;;;GBK&quot.*;?([0-9]*)&java ${file_base_name} &echo: &^(;, &#47, &javac&${file_path}&quot.打开Sublime Text 3:;start&:([0-9]*): &quot.&c是执行完命令后关闭cmd窗口;.,&#47: [&: &quot,&. & pause&quot.java&quot方法一;k是执行完命令后不关闭cmd窗口;:{& pause命令使cmd窗口按任意键后才关闭 &quot:打开Sublime Text 3,粘贴下面的代码并保存关闭?): &quot:{&:&], Browse Packages,&quot.sublime-build,在打开的窗口中双击User文件夹;GBK&quot.安装JDK并配置环境变量2.,&quot: &quot,右键选编辑,&}保存后即可在Sublime Text 3中按Ctrl+B编译Java运行文件; echo, &/cmd&/c& /;Ru......余下全文>>
n&name&.java&variants&;file_regex&UTF-8&quot, Browse Packages:&quot: [ { &quot.,如果程序需要输入内容;file_regex&quot,这种方法的缺点是无法在控制台输入;shell_cmd&quot
1个回答2个回答1个回答1个回答2个回答1个回答1个回答2个回答3个回答
相关文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 中国学网 版权所有
京ICP备号-1 京公网安备02号

我要回帖

更多关于 sublime text 3编写c 的文章

 

随机推荐