顯示側板的文件夾:php
View -> Side Barhtml
菜單【project】-》add folder to project.把文件夾顯示在左邊的sidebar上。java
安裝插件:python
package controllinux
通俗易懂地說,這個是你在完成安裝SublimeText後必須安裝的東西。你問爲何?由於有了這個特殊的「插件包」,你能夠很容易地安裝、升級、刪除,甚至很是方便地查看您已經安裝在SublimeText中的包或插件的列表。它經過菜單和對應的行爲使這些過程變得很是容易和有組織。nginx
1) 按Ctrl+`調出console, 粘貼如下代碼到底部命令行並回車:git
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
2)重啓Sublime Text 2。github
若是在Perferences->package settings中看到package control這一項,則安裝成功。正則表達式
安裝sftp:chrome
按下Ctrl+Shift+P調出命令面板
輸入install 調出 Install Package 選項並回車,而後輸入ftp,下拉列表中會出現一些相關的插件,選中sftp進行安裝就好了,裝好後還需配置以下:選菜單欄中的File->SFTP/FTP->Set up Server,而後出現一個配置窗口以下,
輸入相關的配置信息就能夠了。參考:http://www.icultivator.com/p/1257.html
如何在sidebar列出服務器文件夾,並進行編輯。
"sync_down_on_open": true, 默認true,
一篇文章:
總結: 本文介紹兩種方法,推薦第二種方法(samba+windows映射)
先貼出sublime打開遠程(Linux)目錄所需的配置文件(sublime是經過ssh協議從Linux端下載上傳文件,來保持同步的,下邊的配置文件一部分就是配置ssh,另外一部分配置所要打開的Linux目錄)
{ // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "sftp", "save_before_upload": true, "upload_on_save": true, "sync_down_on_open": true, "sync_skip_deletes": false, "sync_same_age": true, "confirm_downloads": false, "confirm_sync": false, "confirm_overwrite_newer": false, "host": "192.0.0.0", "user": "username", "password": "123456", "port": "22", "remote_path": "/usr/local/mydir", "ignore_regexes": [ "\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json", "sftp-settings\\.json", "/venv/", "\\.svn/", "\\.hg/", "\\.git/", "\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini", "\\.png", "\\.jpg" ], //"file_permissions": "664", //"dir_permissions": "775", "extra_list_connections": 4, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ftp_obey_passive_host": false, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], "preserve_modification_times": true, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", //"allow_config_upload": false, }
(選中文件夾,選中SFTP/FTP->map to remote,會出現如上sftp-config.json,
remote_path這個路徑服務器必定要存在,否則上傳時會報錯說路徑不存在,另外我想把這文件夾A上傳到nginx的html下面
路徑寫/opt/nginx/html/a ,後面要帶a,不然是把本地A文件夾下的文件傳輸到html目錄
在sftp-config文件中,屬性ignore_regexes則是表示排除一些文件,這些排除掉掉文件則不和服務器進行同步。
參考連接:https://wbond.net/sublime_packages/sftp/settings
注: 能夠把 sftp-config.json 文件中的 "upload_on_save" 設置爲‘true’,這樣修改完文件將會自動上傳到服務器上
注意:若是編碼引發錯誤,多是文件名字有亂碼,刪掉這些文件;或者在上邊貼出的配置文件中,根據後綴將其忽略掉,不down下來)
)
第一步:先在本地建立一個文件夾,用sublime打開
第二步:右鍵左側sidbar中這個文件圖標,選擇SFTP/FTP: SFTP > Map to Remote…
第三步:在彈出的配置文件(如上)中修改相應的配置,ssh的ip,用戶名,密碼,想要打開的目錄等等
第三步:右鍵文件圖標,SFTP > Download Folder,而後等待同步完成
(若是出錯,多是編碼的問題,忽略掉編碼不正確的文件,或者修改編碼,而後再SFTP > sync remote->local)
原文:http://wbond.net/sublime_packages/sftp/sidebar
注意:若是編碼引發錯誤,多是文件名字有亂碼,刪掉這些文件;或者在上邊貼出的配置文件中,根據後綴將其忽略掉,不down下來
-------------------新方法線------------------------
2014年5月7日 10:08:03
或者簡單一點兒,在Linux機上開啓samba服務,在windows中將Linux中那個文件夾映射到windows的一個"驅動器"上,
再用sublime text 打開,省的亂碼的糾結了,可是要注意Linux上文件的修改權限
2014年5月23日 17:59:58
還有,使用sublime建立project能夠經過往這個project添加文件夾的方式,同時打開多個上一步創建的windows端映射驅動器.
因爲配置 "upload_on_save": true,修改保存後會自動上傳至遠程服務器。
關閉 sublime 後,下次打開時不會記住側欄的 folders,經過 project 能夠方便的管理。
添加:
Project > Add Folder to Project
也能夠直接把目錄拖到 sublime 中
保存、編輯:
Project > Save Project As
點擊保存,將在選定的目錄生成兩個文件:
project_name.sumlime-project:包含工程定義,該文件會被記錄到版本控制裏。
project_name.sublim-workspace:包含了用戶的工程數據,例如打開的文件和修改等,該文件不會被記錄到版本控制裏。
在 *.sublime-project 文件中( Project > Edit Project),能夠定義工程配置。例如能夠定義多個目錄路徑,或者哪些目錄或文件須要排除在外。經過定義 「name」,能夠將一些長路徑或者名字很長的目錄以更簡潔的名稱顯示在 sidebar 中。
例
{
"folders":
[
在當前項目中快速搜索文件
快捷鍵:CTRL + p
這裏面有技巧,好比但願搜索以下路徑的文件名並打開:
routes/user/messages.js
只需在窗口輸入:rum
或者r/u/m。
Use Goto Anything to open files with only a few keystrokes, and instantly jump to symbols, lines or words.
Triggered with Ctrl+P, it is possible to:
Type part of a file name to open it.
Type @ to jump to symbols, # to search within the file, and : to go to a line number.
These shortcuts can be combined, so tp@rf may take you to a function read_file within a file text_parser.py. Similarly, tp:100 would take you to line 100 of the same file.
更換主題:
Soda 這個主題不錯。有白色能夠選。
Ctrl+Shift+p 輸入install,接着輸入 soda,選擇 Theme - Soda ,enter便可;
默認的theme爲:
// The theme controls the look of Sublime Text's UI (buttons, tabs, scroll bars, etc)
"theme": "Default.sublime-theme",
在setting-user覆蓋:
"theme": "Soda Light 3.sublime-theme",
保存後發現咱們的背景色仍是黑色,這是由於主題改變的是主題顏色,背景色是代碼顏色,更改preference->color scheme
Sublime Text3基本界面等參數設置?
Sublime Text3默認界面設置配置文件在Preferences---->Settings-Default。
咱們能夠經過在Settings-User配置文件中增長值來覆蓋Setting-Default中的設置值,設置值的格式能夠參看Setting-Default配置文件中設置,例以下面我設置的字體大小、行高亮顯示和側邊欄文件夾圖標加粗。設置完成後Ctrl+S保存後,無需重啓Sublime Text3便可當即生效。如修改:
{
"highlight_line":true,
"font_size": 30,
}
設置字體:
"font_face": "Courier New"
BracketHighlighter 高亮顯示匹配的括號、引號和標籤
BracketHighlighter這個插件能在左側高亮顯示匹配的括號、引號和標籤,能匹配的 []
, ()
, {}
, ""
, ''
, <tag></tag>等甚至是自定義的標籤,當看到密密麻麻的代碼分不清標籤之間包容嵌套的關係時,這款插件就能很好地幫你理清楚代碼結構,快速定位括號,引號和標籤內的範圍。
BracketHighlighter能爲ST提供括號,引號這類高亮功能,但安裝此插件後,默認沒有高亮,只有下劃線表示,不是很醒目,須要以下配置
1. 在ST中用package control安裝BracketHighlighter(此是廢話)
2. 安裝完成後,打開Preferences -> package settings -> Bracket Highlighter -> Bracket Settings – User (注意是user),而後添加以下代碼
{ "bracket_styles": { "default": { "icon": "dot", // "color": "entity.name.class", "color": "brackethighlighter.default", "style": "highlight" }, "unmatched": { "icon": "question", "color": "brackethighlighter.unmatched", "style": "highlight" }, "curly": { "icon": "curly_bracket", "color": "brackethighlighter.curly", "style": "highlight" }, "round": { "icon": "round_bracket", "color": "brackethighlighter.round", "style": "highlight" }, "square": { "icon": "square_bracket", "color": "brackethighlighter.square", "style": "highlight" }, "angle": { "icon": "angle_bracket", "color": "brackethighlighter.angle", "style": "highlight" }, "tag": { "icon": "tag", "color": "brackethighlighter.tag", "style": "highlight" }, "single_quote": { "icon": "single_quote", "color": "brackethighlighter.quote", "style": "highlight" }, "double_quote": { "icon": "double_quote", "color": "brackethighlighter.quote", "style": "highlight" }, "regex": { "icon": "regex", "color": "brackethighlighter.quote", "style": "outline" } } }
3. 在ST的安裝目錄中打開packages/user/你的主題.tmTheme,在項裏添加以下代碼
<!-- Bracket 開始 --> <dict> <key>name</key> <string>Bracket Default</string> <key>scope</key> <string>brackethighlighter.default</string> <key>settings</key> <dict> <key>foreground</key> <string>#FFFFFF</string> <key>background</key> <string>#A6E22E</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Unmatched</string> <key>scope</key> <string>brackethighlighter.unmatched</string> <key>settings</key> <dict> <key>foreground</key> <string>#FFFFFF</string> <key>background</key> <string>#FF0000</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Curly</string> <key>scope</key> <string>brackethighlighter.curly</string> <key>settings</key> <dict> <key>foreground</key> <string>#FF00FF</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Round</string> <key>scope</key> <string>brackethighlighter.round</string> <key>settings</key> <dict> <key>foreground</key> <string>#E7FF04</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Square</string> <key>scope</key> <string>brackethighlighter.square</string> <key>settings</key> <dict> <key>foreground</key> <string>#FE4800</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Angle</string> <key>scope</key> <string>brackethighlighter.angle</string> <key>settings</key> <dict> <key>foreground</key> <string>#02F78E</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Tag</string> <key>scope</key> <string>brackethighlighter.tag</string> <key>settings</key> <dict> <key>foreground</key> <string>#FFFFFF</string> <key>background</key> <string>#0080FF</string> </dict> </dict> <dict> <key>name</key> <string>Bracket Quote</string> <key>scope</key> <string>brackethighlighter.quote</string> <key>settings</key> <dict> <key>foreground</key> <string>#56FF00</string> </dict> </dict> <!-- Bracket 結束 -->
爲某個格式文件設置高亮
好比你有一大堆txt文件,可是這些txt文件內容是python代碼,想要打開txt就用python語法高亮,怎麼作,參考下面的:
Sublime Text對於一些常見的擴展名的文件都可以識別並選擇Sublime Text內置對應的高亮語法,可是對於一些使用頻率比較少的擴展名文件就沒法識別,Sublime Text打開此類文件後默認顯示成普通文本,沒有語法高亮。
雖然咱們能夠在打開文件後點擊右下角的Plain Text,在出現的文件格式中選擇本身要顯示的語法類型。
可是這樣每次打開都須要手動進行一番設置,咱們須要一種一勞永逸的方法對此類文件類型進行自動選擇語法高亮。
Sublime Text 2版本添加擴展名文件語法是在Data\Packages目錄下的文件類型目錄裏的文件類型語言文件,如XML\XML.tmlanguage。而後打開該文件,在<key>fileTypes</key>下面按照原來的例子添加新的文件類型保存便可。
而Sublime Text 3的目錄結構和2的不太同樣,使用2的方法就不行了。那麼有2中方法能夠實現,下面的其一方法在2中也可使用,不一樣是的下面的其二方法。
其一:打開文件後點擊右下角的Plain Text,在出現的文件格式中選擇open all with current extension as… ->"須要顯示的語法類型"。這樣之後打開這個類型的文件就會自動進行語法高亮了。
其二:在Data\Packages\User目錄下手動生成一個名字叫XXX.sublime-settings的文件。XXX爲文件擴展名。
在文件內輸入:
{
"extensions":
[
"html",
"dwt",
"lbi"
]
}
添加其餘文件類型以此類推...
增長vim支持,在本身的配置文件裏面,去掉
ignored_packages": ["vintage"] 這個就好了。vintage是vim的包。
sublime ctrl+d 選擇單詞,重複可增長選擇下一個相同的單詞.
sublime不支持除utf8之外的文字亂碼解決
裝插件:ConvertToUTF8,其實也不是真的支持其餘編碼,更準確的應該說是把除UTF8編碼以外的其餘編碼在Sublime Text中轉換稱UTF8編碼,可是在保存的時候仍是原來的那個編碼,從在打開該文件的時候一開始顯示的亂碼,而後一剎那又自動顯示出正常的字體能夠看出,固然,在保存文件以後發現其編碼仍是原來的那個的。
那麼應該如何安裝ConvertToUTF8呢?
一、經過ctrl+shift+p快捷鍵組合打開命令面板輸入」install package」後回車(在此步驟以前請先確認已經安裝好package control)
二、在安裝面板上輸入」ConvertToUTF8″後回車
三、安靜等待安裝,此時會出現介紹頁面,同時可實時查看左下角狀態欄信息瞭解安裝狀況,建議安裝後重啓一下Sublime Text
參考:http://www.cnblogs.com/ifantastic/p/3485943.html
http://blog.jobbole.com/23949/
http://blog.csdn.net/yongan1006/article/details/8806883
http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html
svn插件使用:
Sublime TortoiseSVN 插件爲你提供了在sublime中直接對文件以及文件夾進行svn操做的功能。
它的實現依賴於TortoiseSVN命令行工具TortoiseProc.exe,所以爲了保證插件的順利運行,您的電腦必須已安裝TortoiseProc.exe。
若是沒有請從新安裝TortoiseSVN。(TortoiseSVN 安裝過程當中會有是否安裝命令行工具的選項,默認是不勾選的,從新安裝時請手工勾選).
TortoiseSVN
-----------
Sublime-TortoiseSVN
=============
sublime-TortoiseSVN is a tiny and simple plugin for [Sublime Text](http://www.sublimetext.com) .
It's behavior is similar to [subclipse](http://subclipse.tigris.org/) in [Eclipse](http://www.eclipse.org/).
**It runs only on Windows and needs the TortoiseSVN and TortoiseSVN command line tools (TortoiseProc.exe).**
Usage
============
Install it using [Sublime Package Control](http://wbond.net/sublime_packages/package_control).
If TortoiseSVN is not installed at `C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe`, specify the correct path
by setting property "tortoiseproc_path" in your TortoiseSVN.sublime-settings file.
The default key bindings are
- [alt+c] : commit current file.
- [alt+u] : update current file.
- [alt+r] : revert current file.
You can also call TortoiseSVN commands when right-clicking folders or files in the side bar.
sidebar擴展插件。
SideBarEnhancements本是加強側邊欄的插件,這裏將教你們如何用來作sublime text 3瀏覽器預覽插件,並可自定義瀏覽器預覽的快捷鍵。
安裝此插件,點擊工具欄的preferences > package setting > side bar > Key Building-User,鍵入如下代碼,這裏設置按Ctrl+Shift+C複製文件路徑,按F1~F5分別在firefox,chrome,IE,safari,opera瀏覽器預覽效果,固然你也能夠本身定義喜歡的快捷鍵,最後注意代碼中的瀏覽器路徑要以本身電腦裏的文件路徑爲準。
[
/*{ "keys": ["alt+f12"], "command": "side_bar_open_in_browser", "args":{"paths":[], "type":"production", "browser":""} },*/ { "keys": ["ctrl+shift+c"], "command": "copy_path" }, //chrome { "keys": ["f1"], "command": "side_bar_files_open_with", "args": { "paths": [], "application": "C://Program Files (x86)//Google//Chrome//Application//chrome.exe", "extensions":".*" } }, //firefox { "keys": ["f2"], "command": "side_bar_files_open_with", "args": { "paths": [], "application": "E://軟件//Firefox//firefox.exe", "extensions":".*" //匹配任何文件類型 } }, //ie { "keys": ["f3"], "command": "side_bar_files_open_with", "args": { "paths": [], "application": "C://Program Files//Internet Explorer//iexplore.exe", "extensions":".*" } }, ]
Centos 安裝Sublime text 3
注意:安裝目錄因人而異,個人安裝目錄是/opt/sublime_text_3.
# mkdir /opt # cd /opt
http://www.sublimetext.com/3
注意必定要下Ubuntu/tarball包。
也能夠用命令下載
wget http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x64.tar.bz2
若是連接地址失效,請到官網獲取最新下載地址。
tar jxvf sublime_text_3_build_3059_x64.tar.bz2
# cd /opt/sublime_text_3 # ./sublime_text
複製文件
# cp /opt/sublime_text_3/sublime_text.desktop /usr/share/applications
更改配置文件
# vim /usr/share/applications/sublime_text.desktop 個人配置以下 [Desktop Entry] Version=1.0 Type=Application Name=Sublime Text GenericName=Text Editor Comment=Sophisticated text editor for code, markup and prose Exec=/opt/sublime_text_3/sublime_text %F Terminal=false MimeType=text/plain; Icon=/opt/sublime_text_3/Icon/48x48/sublime-text.png Categories=TextEditor;Development; StartupNotify=true Actions=Window;Document; [Desktop Action Window] Name=New Window Exec=/opt/sublime_text_3/sublime_text -n OnlyShowIn=Unity; [Desktop Action Document] Name=New File Exec=/opt/sublime_text/sublime_text_3 --command new_file OnlyShowIn=Unity;
應用程序 >編程 > Sublime Text」右鍵」將此啓動器添加到桌面」
注意:配置文件標註紅色的地方對應的是軟件安裝目錄,須要改爲你本身的安裝目錄。
設置theme和color scheme
保存以後發現怎麼代碼區域仍是黑色的背景,菜單欄顏色已經切換了,別急,這裏還少了一步,就是配置一下color scheme
The Soda Light screenshot uses a modified version of Espresso Tutti Colori and the Soda Dark screenshot uses a modified version of Monokai.
If you'd like to use the syntax highlighting schemes shown in the screenshots:
tmtheme
files in the Sublime Text Packages/User
folderPreferences -> Color Scheme -> User
sublime構建系統 build system
${folder}是最上層的目標的絕對路徑,也就是game1目標
http://sublime-text.readthedocs.io/en/latest/reference/build_systems.html
Build Systems
Build systems let you run your files through external programs and see the output they generate within Sublime Text.
構建系統可讓您經過外部程序來運行文件,並能夠在Sublime Text查看輸出。
Build systems consist of two –or optionally three– parts:
configuration data in JSON format (the .sublime-build file contents)
a Sublime Text command driving the build process
optionally, an external executable file (script, binary file)
構建系統包括兩 – 或者說三個 – 部分
使用JSON格式保存配置文件 (.sublime-build 內容)
使用Sublime Text命令來驅動構建過程
還包括一個外部的可執行程序(腳本或者二進制)
Essentially, .sublime-build files are configuration data for an external program as well as for the Sublime Text command just mentioned. In them, you specify the switches, options and environment information you want forwarded.
從根本上來說,.sublime-build 配置文件對於外部可執行程序與前面提到的Sublime Text命令是同樣的。在配置文件中能夠指定開關、配置以及環境變量。
The Sublime Text command then receives the data stored in the .sublime-build file. At this point, it can do whatever it needs to build the files. By default, build systems will use the exec command, implemented in Packages/Default/exec.py. As we’ll explain below, you can override this command.
Sublime Text命令從 .sublime-build 中讀取配置數據,而後根據須要*構建*這些文件。 構建系統缺省會使用``exec`` 命令,該命令在 Packages/Default/exec.py 中實現。 在後續的講解中,咱們會重寫這個命令。
Lastly, the external program may be a shell script you’ve created to process your files, or a well-known utility like make or tidy. Usually, these executable files will receive paths to files or directories, along with switches and options to be run with.
外部程序多是你用來處理文件的腳本,也能夠能是相似 make 或 tidy 這類的命令。一般,這些可執行文件從配置中獲取文件路徑或者目錄以及運行是須要的開關及選項。
Note that build systems need not call any external program at all if there isn’t any reason to; you could implement a build system entirely in a Sublime Text command.
注意,構建系統能夠徹底不依賴調用外部程序,徹底能夠經過Sublime Text
文件格式
.構建系統 文件使用JSON. 如下是一個例子:
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
選項
cmd
Array containing the command to run and its desired arguments. If you don’t specify an absolute path, the external program will be searched in your PATH, one of your system’s environmental variables.
cmd
包括命令及其參數數組。若是不指定絕對路徑,外部程序會在你係統的:const:PATH 環境變量中搜索。
On Windows, GUIs are supressed.
在Windows 系統中,*TBT*
file_regex
Optional. Regular expression (Perl-style) to capture error output of cmd. See the next section for details.
file_regex
可選。 Perl格式的正則表達式能夠獲取``cmd``的錯誤輸出,詳情參考下一節
line_regex
Optional. If file_regex doesn’t match on the current line, but line_regex exists, and it does match on the current line, then walk backwards through the buffer until a line matching file regex is found, and use these two matches to determine the file and line to go to.
line_regex
可選。當``file_regex``與該行不匹配,若是``line_regex``存在,而且確實與當前行匹配, 則遍歷整個緩衝區,直到與``file regex``匹配的行出現,並用這兩個匹配決定最終要跳轉的文件 或行。
selector
Optional. Used when Tools | Build System | Automatic is set to true. Sublime Text uses this scope selector to find the appropriate build system for the active view.
selector
可選。在選定 Tools | Build System | Automatic 時使用。Sublime Text使用這個 選擇器自動爲活動試圖選擇構建系統。
working_dir
Optional. Directory to change the current directory to before running cmd. The original current directory is restored afterwards.
working_dir
可選。在運行``cmd``前會切換到該目錄。運行結束後會切換到原來的目錄。
encoding
Optional. Output encoding of cmd. Must be a valid python encoding. Defaults to UTF-8.
encoding
可選。輸出``cmd``的編碼。必須是合法的Python編碼,缺省爲``UTF-8``。
target
Optional. Sublime Text command to run. Defaults to exec (Packages/Default/exec.py). This command receives the configuration data specified in the .build-system file.
Used to override the default build system command. Note that if you choose to override the default command for build systems, you can add arbitrary variables in the .sublime-build file.
target
可選。運行的Sublime Text命令,缺省爲``exec`` (Packages/Default/exec.py)。該命令從 *.build-system*中獲取配置數據。
用來替代缺省的構建系統命令。注意,若是你但願替代構建系統的缺省命令,請在*.sublime-build* 文件中專門設置。
env
Optional. Dictionary of environment variables to be merged with the current process’ before passing them to cmd.
Use this element, for example, to add or modify environment variables without modifying your system’s settings.
env
可選。在環境變量被傳遞給``cmd``前,將他們封裝成詞典。
shell
Optional. If true, cmd will be run through the shell (cmd.exe, bash…).
shell
可選。若是該選項爲``true`` ,``cmd``則能夠經過shell運行。
path
Optional. This string will replace the current process’ PATH before calling cmd. The old PATHvalue will be restored after that.
Use this option to add directories to PATH without having to modify your system’s settings.
path
可選。該選項能夠在調用``cmd``前替換當前進程的’ PATH 。原來的’ PATH 將在運行後恢復。
使用這個選項能夠在不修改系統設置的前提下將目錄添加到’ PATH 中。
variants
Optional. A list of dictionaries of options to override the main build system’s options. Variant ``name``s will appear in the Command Palette for easy access if the build system’s selector matches for the active file.
variants
可選。用來替代主構建系統的備選。若是構建系統的選擇器與激活的文件匹配,變量的``名稱``則 會出如今 Command Palette 中。
name
Only valid inside a variant (see variants). Identifies variant build systems. If name is Run, the variant will show up under the Tools | Build System menu and be bound to Ctrl + Shift + B.
name
僅在variant中是合法的 (詳見 variants)。用來標識系統中不一樣的構建系統。若是 ``name``是*Run* ,則會顯示在**Tools | Build System** 下,而且可使用 *Ctrl + Shift + B*調用。
使用 ``file_regex``獲取錯誤輸出
The file_regex option uses a Perl-style regular expression to capture up to four fields of error information from the build program’s output, namely: file name, line number, column number and error message. Use groups in the pattern to capture this information. The file name field and the line number field are required.
``file_regex``選項用Perl的正則表達式來捕獲構建系統的錯誤輸出,主要包括四部份內容,分別是 file name*, line number, column number and error message. Sublime Text 在匹配模式中使用分組的方式捕獲信息。file name 和 *line number*域是必須的。
When error information is captured, you can navigate to error instances in your project’s files with F4 and Shift+F4. If available, the captured error message will be displayed in the status bar.
當錯誤信息被捕獲時,你可使用``F4`` 和 ``Shift+F4``在你的項目文件中跳轉。被捕獲的*錯誤 信息*會顯示在狀態欄。
平臺相關選項
The windows, osx and linux elements let you provide platform-specific data in the build system. Here’s an example:
``windows``, ``osx`` 以及 ``linux``元素能夠幫助你在構建系統中設定平臺相關
的選項,舉例以下:
{
「cmd」: [「ant」], 「file_regex」: 「^
javac
javac
(.+):([0-9]+):() (.)$」, 「working_dir」: 「${project_path:${folder}}」, 「selector」: 「source.java」,
「windows」: {
「cmd」: [「ant.bat」]
}
}
In this case, ant will be executed for every platform except Windows, where ant.bat will be used instead.
在這個例子中,ant``在除了Windows以外的平臺中都是執行 ant ,而在Windows中則執行 ``ant.bat
構建系統備選項
以下是一個帶有備選項的構建系統實例:
{
"selector": "source.python",
"cmd": ["date"],
"variants": [
{ "cmd": ["ls -l *.py"],
"name": "List Python Files",
"shell": true
},
{ "cmd": ["wc", "$file"],
"name": "Word Count (current file)"
},
{ "cmd": ["python", "-u", "$file"],
"name": "Run"
}
]
}
Given these settings, Ctrl + B would run the date command, Crtl + Shift + B would run the Python interpreter and the remaining variants would appear in the Command Palette whenever the build system was active.
根據以上的設定,按 Ctrl + B 會運行*date*命令, 按 Crtl + Shift + B 會運行Python 解釋器,而且在構建系統激活時將剩餘的備選項顯示在Command Palette中。
構建系統變量
Build systems expand the following variables in .sublime-build files:
在*.sublime-build* 中包括以下構建系統變量。
$file_path 當前文件所在路徑, 好比 C:\Files.
$file 當前文件的完整路徑, 好比 C:\Files\Chapter1.txt.
$file_name 當前文件的文件名, 好比 Chapter1.txt.
$file_extension 當前文件的擴展名, 好比 txt.
$file_base_name 當前文件僅包含文件名的部分, 好比 Document.
$packages Packages 文件夾的完整路徑.
$project 當前項目文件的完整路徑.
$project_path 當前項目文件的路徑.
$project_name 當前項目文件的名稱.
$project_extension 當前項目文件的擴展部分.
$project_base_name 當前項目僅包括名的部分.
變量用法
Features found in snippets can be used with these variables. For example:
能夠在代碼片斷上中使用以上變量。例如:
${project_name:Default}
This will emit the name of the current project if there is one, otherwise Default.
若是當前項目存在則使用該項目名稱,不然則使用``Default``替代
${file/\.php/\.txt/}
This will emit the full path of the current file, replacing .php with .txt.
該例會獲取當前文件的完整路徑,並用*.txt*替換路徑中的*.php*
運行構建系統
Select the desired build system from Tools | Build System, and then select Tools | Build or press F7.
從**Tools | Build System**選擇構建系統,而後選擇**Tools | Build** ,再按``F7``。
構建系統常見問題
Build systems will look for executables in your PATH, unless you specify an absolute path to the executable. Therefore, your PATH variable must be correctly set.
若是你沒有爲構建系統指定一個可執行文件的絕對路徑,構建系統怎麼會在你的 PATH 中進行查找。 因此,你須要正確設置 PATH 。
On some operating systems, the value for PATH will vary from a terminal window to a graphical application. Thus, even if the command you are using in your build system works in the command line, it may not work from Sublime Text. This is due to user profiles in shells.
在某些操做系統中,終端和圖形化應用的 PATH 值會有所不一樣。因此即使你的構建系統在命令行下 能夠正常工做,在Sublime Text也不見得可以正常。這與Shell中的用戶設置有關。
To solve this issue, make sure you set the desired PATH so that graphical applications such as Sublime Text can find it. See the links below for more information.
爲了解決這個問題,請確認你正確設置了 PATH ,以便相似Sublime Text一類的圖形化應用 能夠正確找到。更多內容,請參考一下連接
Alternatively, you can use the path element in .sublime-build files to override the PATH used to locate the executable specified in cmd. This new value for PATH will only be in effect for as long as your build system is running. After that, the old PATH will be restored.
另外,你也能夠在 .sublime-build 文件中設定 path 來替代:const:PATH ,並在 path 指定的路徑中查找 cmd 可執行文件。新設定的值,僅在構建系統運行期間有效,事後將會恢復爲原始的--------------------- 做者:lyctianya 來源:CSDN 原文:https://blog.csdn.net/lyctianya/article/details/70234029 版權聲明:本文爲博主原創文章,轉載請附上博文連接!