-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sublime Text.txt
217 lines (207 loc) · 27.9 KB
/
Sublime Text.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
Documentations:
http://docs.sublimetext.info/en/latest/index.html
http://www.sublimetext.com/docs/3/index.html
https://tutsplus.com/course/improve-workflow-in-sublime-text-2/
http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/
http://sublimetext.info/docs/en/index.html (for ST2 only)
Glossary
:buffer: = Data of a loaded file and additional metadata, associated with one or more views.
:view: = Graphical display of a buffer. Multiple views can show the same buffer.
:panel: = An input/output widget, such as a search panel or the output panel.
:overlay: = An input widget of a special kind, i.e: Menu Goto → Goto Anything.
:Relative: path
Relative to Data Directory (i.e: Packages/User = Sublime Text/Data/Packages/User).
Except for Project is relative to project directory (i.e: "file" field inside *.sublime_project).
2 dots means up 1 level (i.e: ..\\sublime_text.exe = \Sublime Text\sublime_text.exe)
Features (accessible via Menu bar):
Note:
Menubar can contain ST built-in features [[Command.txt#Built-in commands]] or User-defined [[sublime-menu.txt]]
This section only talk about ST built-in features (of course)
To know which menu caption correspond to which commands:
Rename Default.sublime-package → .zip
Extract then open Main.sublime-menu
File
New view into file: open 2 tabs which show the same file (useful for split view [[Split screen.txt]] [[Command.txt#clone_file]])
Revert file: Revert to the state when the file is opened
Edit
Comment = Toggle comment on selected line/block of code, defined in *.tmPreferences [[tmPreferences.txt#Comment:]]
Line
Indent/Unindent
Swap line/Join lines: move lines around
Code Folding:
:Fold: Fold selected text
Fold level X: Fold base on indent level (default) OR base on Blocks defined in tmLanguage [[tmLanguage.txt]]
Fold Tag attribute:
i.e: a HTML tag <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> will be folded to <meta.../>
defined in tmLanguage [[tmLanguage.txt#Define Tag]]
Text → Transpose: Swap multiple selected text with each other
Permute:
Reverse & Suffle = Sort selected text
Unique = delete duplicate
Wrap at ruler
Mark:
Emac-style cut and paste
Yank
After text has been killed, it goes to a place called the kill ring which is analagous to the "clipboard"
you can yank an item to restore it from the kill ring with C-y (pasting text)
Unlike the clipboard, however, the kill ring is capable of holding many different items.
If the item you want to yank is not placed when you type C-y, type M-y (repeatedly, if necessary) to cycle through previously killed items.
Tag
Close Tag: i.e HTML: <head> blah blah → <head> blah blah </head>
Expand selection to tag
Define tag in [[tmLanguage.txt#Define Tag]]
Selection
Expand Selection to Line/Paragraph/Scope/Bracket/Indent...
Add previous/next line: Add multiple cursor at the prev/next line (at the same column) [[obj\Multiple cursor.gif]]
Split into lines: Select a paragraph with multiple lines → Split into lines → multiple cursors are place at the end of each lines
Find
Find (ctrl+f): Find/Replace in current buffer (single file mode)
Incremental Find: The same as Find but pressing Enter will dismiss the search panel (similar as Goto #)
Quick find: Find text under cursor without display Find panel
Quick add next (ctrl+d): Add next occurence of selected text into a multiple selection
Find in Files: [[obj\Find in Files.png]]
Find/Replace accross multiple files.
"Where" field:
If blank, then default to <open folders> (all files&folders in current project = everything in side bar plus all opened files) [[#Side bar]]
can combine multiple criteria by comma-separated i.e: D:\Doc\IT,*.txt,<open folders>,D:\Doc\Reference,-*.html
To exclude folder:
use "-" i.e: -/Sublime/Data
"\" can be only used for absolute path in Windows, i.e: -C:\Test
"Use Buffer" button: Find result is shown in a separate tab instead of a pane in the bottom of screen
Tip: In "Where" field:, Press ctrl+enter to search accross multiple lines
Tip: Find all blank line: enable Regex then search for either of these terms: ^\s+$ ^\n ^(\r|\n\r?)
ST use PCRE Regex http://www.regular-expressions.info/pcre.html http://www.boost.org/doc/libs/1_47_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
View
Layout = Split Screen [[obj\Split screen.png]] [[Split screen.txt]]
Group = When on splitted screen, ctrl+shift+2 will move current tab to 2nd sceen, ctrl+shift+3 to 3rd...
Syntax = Syntax Highlighting [[tmLanguage.txt]]
Distraction Free Mode
Tidy screen with nothing (no tab bar, no menu, no statusbar...) but your text
Default [[sublime-settings.txt#Distraction Free.sublime-settings]]:
{
"line_numbers": false,
"gutter": false,
"draw_centered": true,
"wrap_width": 80,
"word_wrap": true,
"scroll_past_end": true
}
Side bar
Must add file/folder into side bar before it can be shown (Project > Add folder to Project...) [[Project.txt]]
Files and folders added to sidebar are available in Goto Anything and other project-wide actions (i.e: project-wide search)
Single click to preview files in a "preview" tab (tab with italic caption)
Double click to open in new "real" tab
Spell check: To install new dictionary:
Download .oxt file from http://extensions.openoffice.org/en/search?f[0]=field_project_tags%3A157
rename to .zip or .rar then extract to \Data\Packages
Ref: http://www.sublimetext.com/forum/viewtopic.php?f=2&t=7041
:Ruler:
assist Edit → Wrap at ruler
To show permanent ruler: change setting "rulers": [20, 50, 70],
To show temporary ruler: View → Ruler
Goto
Goto Symbol:
A text region define (establishes) a :symbol: when either:
It has a special scope
entity.name.function → This special scope not allow Goto Definition
meta.class → This special scope allow Goto Definition
It has a custom scope (i.e tidea.symbol), then this scope is assigned as symbol [[tmPreferences.txt#showInSymbolList]]
Several symbol definition files can coexist in the same package. ie.: one define all symbols, another selectively hide some of them if they were uninteresting for users.
There're local symbol list (active file) and a global symbol list (project-wide)
Goto Definition = goto definition of symbol under cursor, example:
Using .tmLanguage, you assign a scope "meta.class" to the text region between "def " and (
=> This text region def on_deactivated(self, view): define a symbol "on_deactivated"
Using [[tmPreferences.txt#Symbol:]], you assign these scopes as symbol: "meta.class, entity.name.type, meta.toc-list"
Now, you re-use the function on_deactivated() somewhere else and want to see how and in-which-file it was declared before
Place cusor of on_deactivated() and choose Goto Definition, ST will take you back to def on_deactivated(self, view):
Goto Anything
# = go to word (search within file)
: = go to line number
@ = go to symbols
Combine all the above, i.e:
tp@rf = go to a function read_file within a file text_parser.py
isl#trsr = fuzzy search for trsr in files whose name loosely matches isl (i.e: "treasure" inside file "island.txt")
When prefix with nothing: Goto File (fuzzy search accross all files in sidebar and project)
Jump Back/Forward: go to previous editing positions
Switch file
Header/Implementation: In C or C++ for example, I have separate header and implementation files for all my classes, so if I am working on a class' header and want to switch directly to its implementation file say, this command provides a quick way to do that, without having to find the specific tab in the menu bar, or hunt for in it the project drawer.
Bookmark
Command Pallete (ctrl+shift+p):
List all commands in .sublime-commands [[Command.txt#.sublime-commands]]
Super fast fuzzy search
The list is contextual (not consider all .sublime-commands files)
To have your own command appear in this pallete:
Step 1: Write custom commands stored in *.py [[Plugin.txt]]
Step 2: write .sublime-commands, which refer to command name in *.py [[Command.txt]]
Snippet: Type a few character → press Tab → a template of text is inserted [[Snippet.txt]]
Macro: Execute a series of commands [[Macro.txt]] [[Plugin.txt]]
Build Systems: Open current file with external programs [[Build.txt]]
Project: Collection of files and folders [[Project.txt]]
Preferences
Settings [[sublime-settings.txt]]
Key Bindings [[Key Binding.txt]]
Font > Reset: reset Zoom level (so that font actually equal font-size in settings)
Features not in Menu Bar:
Syntax highlighting:
Syntax definition [[tmLanguage.txt]] assign scope name [[Scope.txt]] (i.e: text.html.bold) to text regions (i.e: <b>...</b>)
Then .tmTheme file [[theme.txt]] decide color/font style for each scope name (i.e: text.html.bold should be red)
AutoComplete: Type a few characters → Auto complete list popup as you type → Tab or Enter to choose [[AutoComplete.txt]]
Indent guide: [[obj\Indent Guide.jpg]]
enable by Preference > "draw_indent_guides": true,
To change color: edit <key>guide</key>; <key>activeGuide</key>; <key>stackGuide</key> in .tmtheme file [[theme.txt]]
Multiple Selections: [[obj\Multiple cursor.gif]]
Ctrl+LMouse: Add to selection
Shift+RMouse drag: Column selection
Ctl+Alt+Up/Down: Add above/below line to selection.
Ctrl+U: Undo selection
Ctrl+Shift+L: split selection into lines
Ctrl+D
If mouse is hovering over a word without any selection → Select entire word
If there's some selection → add the next occurrence of seelcted word (Faster than Find & Replace)
Ctrl+Shift+G: Select all occurence of word under cursor → much faster than find & replace
Escape to return to normal selection (single)
Command-line (subl.exe)
Usage:
subl [arguments] [files] edit the given files
subl [arguments] [directories] open the given directories
subl [arguments] - edit stdin
Arguments:
--project <project>: Load the given project
--command <command>: Run Application command [[Plugin.API.txt#sublime_plugin.ApplicationCommand]] OR User-defined commands
-n or --new-window: Open a new window
-a or --add: Add folders to the current window
-w or --wait: Wait for the files to be closed before returning
-b or --background: Don't activate the application
-s or --stay: Keep the application activated after closing the file
-h or --help: Show help (this message) and exit
-v or --version: Show version and exit
--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).
Filenames may be given a :line or :line:column suffix to open at a specific location.
To edit settings and config: [[File organization.txt]]
Package control
Widely popular user package created by wbond
Manual Install: Copy Package Control.sublime-package to \Data\Installed Packages\ → Restart Sublime
Install via consol: https://sublime.wbond.net/installation
Commands
All Commands are accessed via Command Pallete (ctrl+shift+p)
Install Package: List packages from https://sublime.wbond.net/browse + repositories you have added
Add Repository
https://github.com/username/repo
https://bitbucket.org/username/repository
Remove Package
Create Package File: Creates .sublime-package file from package folder (For developers)
Create Binary Package File:
Creates .sublime-package file that include .pyc bytecode files instead of source .py files
This is useful to distribute commercial packages.
Upgrade/Overwrite All Packages: upgrade ALL packages, including ones that were not installed via Package Control
Upgrade Package: Show a list of packages that are available for upgrade
For Developer
[[Scope.txt]]
[[Plugin.txt]]
[[Command.txt]]
Features not yet available in Sublime Text
Print
Permanent variable
My settings backup:
"file_include_patterns": ["*.tex", "*.md", "*.css", "*.inf", "*.xml", "*.ahk", "*.dat", "*.bat", "*.vbs", "*.txt", "*.ini", "*.nfo", "*.key", "*.reg", "*.xys", "*.html", "*.htm", "*.sfv", "*.py", "*.sublime*", "*.tmLanguage", "*.tmPreferences", "*.json", "*.tmtheme", "*.hidden-tmTheme", "*.png", "*.jpg"],