Editing
Sublime Text is brim-full of editing features. This topic just scratches the surface of what's possible.
# Multiple Selections
Multiple selections let you make sweeping changes to your text efficiently. Any praise about multiple selections is an understatement. This is why:
Select some text and press Ctrl D to add more instances. If you want to skip the current instance, press Ctrl K, Ctrl D.
If you go too far, press Ctrl U to deselect the current instance.
# Transforming Multiple Selections into Lines
Ctrl L expands the selections to the end of the line. Ctrl ⇧ L splits the selections into lines.You can copy multiple selected lines to a separate buffer, edit them there, select the content again as multiple lines and then paste them back into place in the first buffer.
# Column Selection
You can select a rectangular area of a file. Column selection makes use of multiple selections.
It's possible to add blocks of text to or remove them from the selection.
# Using the Mouse
Windows & Linux
Description | Shortcut |
---|---|
Select Block | ⇧ + Right Mouse Button |
Add to Selection | Ctrl ⇧ + Right Mouse Button |
Remove from Selection | Alt ⇧ + Right Mouse Button |
macOS
Description | Shortcut |
---|---|
Select Block | ⌥ + Left Mouse Button |
Add to Selection | ⌥ ⌘ + Left Mouse Button |
Remove from Selection | ⌥ ⇧ ⌘ + Left Mouse Button |
# Using the Keyboard
System | Shortcut |
---|---|
Windows | Ctrl Alt ↑ and Ctrl Alt ↓ |
Linux | Alt ⇧ ↑ and Alt ⇧ ↓ |
macOS | Ctrl ⇧ ↑ and Ctrl ⇧ ↓ |
# Other Ways of Selecting Text
The list is long; all available options can be found under Selection. To name a few:
- Select subwords (Alt ⇧ ← and Alt ⇧ →)
- Expand selection to brackets (Ctrl ⇧ M)
- Expand selection to indentation (Ctrl ⇧ J)
- Expand selection to scope (Ctrl ⇧ ␣)
# Transposing Things
Need to swap two letters or, better yet, two words? Experiment with Ctrl T.
# Arithmetic
Need to create a series of numbers? Try Ctrl ⇧ P and "Arithmetic".
Best used when having multiple selections.
Expression | Selection | Result |
---|---|---|
1+i | 1, 2, 3, 4, 5, 6, 7, ... | |
30+(i%3) | 30, 31, 32, 30, 31, 32, ... | |
(x*2)+i | 10, 20, 30 | 20, 41, 62 |
math.ceil(x) | 0.25, 2.25 | 1, 3 |
len(s) | house, tree | 5, 4 |
format(s, '^10') | fish | ' fish ' (centered string) |
You can use the following variables:
i
being the index of the selectionx
being the selected numbers
being the selected string
As you can see above you can even use a certain set of built-in python functions:
- docs.python.org/3.8/library/math.html (opens new window)
- docs.python.org/3.8/library/functions.html (opens new window)
- docs.python.org/3.8/library/string.html#formatspec (opens new window)
# And much, much more...
The Edit, Selection, Find and Goto menus are good places to look for handy editing tools. You might end up using just a few of them, but the rest will still be there for when you need them.