Differences between revisions 1 and 2
Revision 1 as of 2014-05-26 15:42:09
Size: 6858
Editor: twotwo
Comment:
Revision 2 as of 2019-07-03 20:22:46
Size: 6857
Editor: twotwo
Comment: Update to V3
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
#title Sublime Text 2
||See Alse [[Python]]、[[Vim]] ||
= Sublime Text 2 =
#title Sublime Text 3
||See Alse [[Visual_Studio_Code|VSCode]]、[[Python]]、[[Vim]] ||
= Sublime Text 3 =
Line 7: Line 7:
Sublime Text 是一个及其强大但小巧的文本编辑器,用来编写代码、标记性语言;支持Mac/Linux/Windows平台。

== 为什么我们都用ST2 ==
Sublime Text 2的评估版可以无限使用,尽管每天会弹出一次提示框让你购买License。

目前最新的是3.0,但必须购买License才能长期使用。

为了简洁的目的,后面吧Sublime Text 2 简称为ST2或者ST。

== 基本概念 ==

ST在默认安装的情况下就支持40多种语言的语法高亮、格式缩进的基本功能,十分的简单实用。而如果想要用的更加舒适简洁也是可以支持的非常妥帖的,要想用得舒爽,还请继续阅读。
=== Packages & Plugins ===
~+Install Package Control First!+~

Press Ctr+`, enter below code and press enter, restart Subline Text
{{{
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
}}}

ST使用了包(Package)的概念,和一些编程语言(例如Java)的含义类似,都是指在一个目录里为完成一个目的而存在的多个文件;显而易见,插件也是用包的形式来组织和存储的。
Sublime Text 是一套跨平台的文本编辑器,支持基于Python的插件。Sublime Text 是专有软件,可透过包(Package)扩展。大多数的包使用自由软件授权发布,并由社群建置维护;支持Mac/Linux/Windows平台。

== 为啥升到ST3 ==
发现 Sublime Text 3的评估版也可以无限使用。

== Features ==
 * “Go to anything”功能:可快速跳至文件、符号或行数
 * “Command palette”功能:弹性快捷键功能
 * 多行选择功能:同时修改多内联容
 * 基于Python语言的外挂API
 * 针对个别项目使用不同的编辑器设置
 * 透过JSON文件自定义设置值
 * 跨平台(Windows、Linux和Mac OS X)
 * 兼容TextMate的语言标记语法

== Setups ==

=== Setting Up Package Control to Work from Behind a Proxy Server ===
[[https://stackoverflow.com/questions/43476308/sublime-text-3-package-control-install||target="_blank"]]

 * `Preferences` -> ``Package Settings`` -> `Package Control`
 * file: `~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings`

{{{
{
    "http_proxy": "server.com:80",
    "https_proxy": "server.com:8080",
    "proxy_username": "mynameis",
    "proxy_password": "mypassis",
}
}}}

=== Command Line ===
[[https://www.sublimetext.com/docs/3/osx_command_line.html||target="_blank"]] OS X Command Line

`ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl`

`export EDITOR='subl -w'`
Line 59: Line 76:

=== Font Settings ===
Preferences ▶ Settings //CMD+,

{{{#!highlight json numbers=disable
{
 //...other configurations
 "font_face": "Monaco",
 "font_size": 14.0,

 "add_before_me": true
}
}}}
Line 112: Line 143:
=== 字体设置 ===

Add in {{{Packages/User/Preferences.sublime-settings}}}
click Preferences → Settings - User / CMD+,

{{{#!json
{
 //...other configurations
 "font_face": "Monaco",
 "font_size": 16.0,

 "add_before_me": true
}
}}}
Line 197: Line 215:
== Packages ==
 * [[https://packagecontrol.io/packages/Pretty%20JSON|Pretty JSON|target="_blank"]] `cmd+ctrl+j`
Line 199: Line 219:
 * [[http://www.sublimetext.com/||target="_blank"]]: sublime text home page
 * [[http://www.sublimetext.com/docs/2/index.html||target="_blank"]]: Sublime Text 2 Documentation
 * [[http://sublime-text-unofficial-documentation.readthedocs.org/en/sublime-text-2/||target="_blank"]]: Sublime Text Unofficial Documentation
 * [[https://en.wikipedia.org/wiki/Sublime_Text||target="_blank"]]
 * [[http://www.sublimetext.com/||target="_blank"]]
 * [[https://www.sublimetext.com/docs/3/||target="_blank"]]
Line 204: Line 224:
[[CategorymacOS]] CategoryTool CategoryDev [[CategorymacOS]] CategoryTool

See Alse VSCodePythonVim

Sublime Text 3

Sublime Text 是一套跨平台的文本编辑器,支持基于Python的插件。Sublime Text 是专有软件,可透过包(Package)扩展。大多数的包使用自由软件授权发布,并由社群建置维护;支持Mac/Linux/Windows平台。

1. 为啥升到ST3

发现 Sublime Text 3的评估版也可以无限使用。

2. Features

  • “Go to anything”功能:可快速跳至文件、符号或行数
  • “Command palette”功能:弹性快捷键功能
  • 多行选择功能:同时修改多内联容
  • 基于Python语言的外挂API
  • 针对个别项目使用不同的编辑器设置
  • 透过JSON文件自定义设置值
  • 跨平台(Windows、Linux和Mac OS X)
  • 兼容TextMate的语言标记语法

3. Setups

3.1. Setting Up Package Control to Work from Behind a Proxy Server

https://stackoverflow.com/questions/43476308/sublime-text-3-package-control-install

  • Preferences -> Package Settings -> Package Control

  • file: ~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings

{
    "http_proxy": "server.com:80",
    "https_proxy": "server.com:8080",
    "proxy_username": "mynameis",
    "proxy_password": "mypassis",
}

3.2. Command Line

https://www.sublimetext.com/docs/3/osx_command_line.html OS X Command Line

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

export EDITOR='subl -w'

3.2.1. The Packages Directory

from the Sublime Text menu: Preferences -> Browse Packages

api call: sublime.packages_path()

3.2.2. Package Management

Cmd+Shift+P(Tools -> Command Palette), Press install and select "Package Control: Install Package" and press enter

Same as Remove Pakcage

List Installed Packages:

        Preferences -> Package Settings

Cmd+Shift+P, search for "Package Control: Remove Package" to remove installed packages

3.2.3. File Navigator(open file by cmd)

https://github.com/csch0/SublimeText-File-Navigator

cmd++shift+o on OSX or ctrl+shift+o on Windows

cmd+o then cmd+shift+g

3.2.4. SublimeGDB(c debugger)

https://github.com/quarnster/SublimeGDB

Install: Cmd+Shift+P, select "Package Control: Install Package" and pree ss enter, type "SublimeGDB", select and install

4. 文本编辑

4.1. Font Settings

Preferences ▶ Settings //CMD+,

{
        //...other configurations
        "font_face": "Monaco",
        "font_size": 14.0,

        "add_before_me": true
}

4.2. 多行选择

Refer 列选择

  • Mouse: Left Mouse Button(OR: Middle Mouse Button) + Option
  • Keyboard: Ctrl + Shift + Up/Down
    • OS X: Go to System Preferences -> Keyboard -> Keyboard Shortcuts, click on Mission Control, uncheck the boxes next to Mission Control and Application windows

4.3. 多选

Refer 键盘多选

  • 加入下一个:Command+D // undo use Command+U
  • 全选: Ctrl+Command+G

5. 查找与替换

6. Building System

编译功能可以按F7键或从菜单 Tools -> Build

6.1. Compile and Run for C programming language

Tools -> Build System -> New Build System

{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}", "-lm", "-Wall"],
"selector" : "source.c",
"shell":false,
"working_dir" : "$file_path", 
 "variants":[
    {
                "name": "Run",
                "cmd": "${file_path}/${file_base_name}" 
        }
]
}

Tools.Build=Cmd+B/Tools.Run=Shift+Cmd+B

7. 订制我的ST2

7.1. 配置文件

在菜单的Preferences下面,对应如下的文件

    Packages/Default/Preferences.sublime-settings
    Packages/Default/Preferences (<platform>).sublime-settings
    Packages/User/Preferences.sublime-settings
    <Project Settings>
    Packages/<syntax>/<syntax>.sublime-settings
    Packages/User/<syntax>.sublime-settings
    <Buffer Specific Settings> 

7.2. 代码缩进(Indentation)

我的习惯是tab, size=4 space, reference here.

Add in Packages/User/Preferences.sublime-settings click Preferences → Settings - User / CMD+,

{
        //...other configurations
        "tab_size": 4,
        "translate_tabs_to_spaces": false,

        "add_before_me": true
}

7.3. 注入代码段(snippets)

reference here.

7.3.1. Config Storage

Snippets can be stored under any package’s folder, but to keep it simple while you’re learning, you can save them to your Packages/User folder.

为了确保代码段配置能保存在Packages/User目录,首先呼出用户配置: CMD+,(Preference | Setting - User),然后选择 Tools | New Snippet

7.3.2. C Head Sample

<snippet>
        <content><![CDATA[
/*==========================================
 *  
 *  $TM_FILENAME: 
 *  author: liyan(twotwo.li@163.com)
 *  
 ==========================================*/
]]></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <!-- <tabTrigger>hello</tabTrigger> -->
        <tabTrigger>head</tabTrigger>
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <!-- <scope>source.python</scope> -->
        <scope>source.c</scope>
        <description>C Head Snippet</description>
</snippet>

Save as head.sublime-snippet

Usage: type head+TAB

7.4. Key Bindings

reference here.

        Preferences → Key Bindings → User

7.4.1. (super+shift+r)Reindent Text in Sublime

https://joshbetz.com/2012/09/reindent-text-in-sublime

[
        //other keys settings seperate by comma,
        {"keys": ["super+shift+r"], "command": "reindent" , "args": {"single_line": false}}
]

7.4.2. (super+r)list functions

7.4.3. (super+x)line delete

8. Packages

9. Reference


CategorymacOS CategoryTool

MainWiki: Sublime_Text (last edited 2019-07-03 20:22:46 by twotwo)