index.md 3.95 KB
Newer Older
Vincent Tam's avatar
Vincent Tam committed
1 2
---
title: "Sublime Text 3"
3
subtitle: "An overview of my Sublime Text 3 Config"
Vincent Tam's avatar
Vincent Tam committed
4 5 6 7 8 9 10
date: 2018-09-05T20:52:51+02:00
type: page
draft: false
---

### <i class="far fa-keyboard" aria-hidden></i> Usual keys

Vincent Tam's avatar
Vincent Tam committed
11
#### <i class="fas fa-arrows-alt" aria-hidden></i> Navigation
Vincent Tam's avatar
Vincent Tam committed
12

13
- `<C-Up>` / `<C-Down>`: move up ↑ / down ↓ _without_ changing cursor
Vincent Tam's avatar
Vincent Tam committed
14 15 16 17 18 19 20 21 22 23 24 25
<i class="fas fa-i-cursor" aria-hidden></i> position.
- `<C-g>`: go to line number
- `<C-p>`: go to other files
- `<C-S-p>`: show [Command Palette][stcsp]

#### <i class="fas fa-search" aria-hidden></i> Searching / Replacing

As usual, support custom selection range and regular expression as expected.
Transformations preserving cases are possible.

#### <i class="far fa-edit" aria-hidden></i> Editing / Selection

26 27
- `<F6>`: toogle spell check
- `<C-F6>` / `<S-C-F6>`: next / previous spelling mistake
Vincent Tam's avatar
Vincent Tam committed
28 29
- `<C-Enter>` / `<C-S-Enter>`: insert empty new line below / above current line.
Works like `o` / `O` in [Vim].
30
- `<C-S-Up>` / `<C-S-Down>`: swap current line up ↑ / down ↓
Vincent Tam's avatar
Vincent Tam committed
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
- `<C-S-d>`: duplicate current line
- `<C-l>`: select current line and move cursor to the beginning of next line

Multi-cursors:

- `<C-d>`: select next match of current word
- `<C-S-l>`: select highlighted lines and move cursurs to the end of lines.  Use
`<Esc>` to undo.

In HTML/[Markdown][md] files:

- `<C-S>`: toogle comment for the current line

### <i class="fas fa-user-cog" aria-hidden></i> User config

The _User Settings_ file, written in JSON, can be opened with **Sublime Text >
Preferences > Settings** -- User.  After changing the file, _restart_ it to
apply the changed settings.

#### <i class="fas fa-indent" aria-hidden></i> Expand tabs to spaces

At the right-bottom corner, there's a "Spaces: [num]", where "[num]" represents
your tab width.  Click on that to open a popup menu.  You may click "**Convert
indentation to Spaces/Tabs**" at the bottom.  The appropriate choice at the top
will be automatically made.

To make this preference persistent, you may set `"translate_tabs_to_spaces":
true`.

<i class="fas fa-info-circle" aria-hidden></i> Tabs should be _avoided_ in
source code <i class="far fa-file-code" aria-hidden></i>  and text files <i
class="far fa-file-alt" aria-hidden></i> unless necessary.  (say, [Makefile])

Further reading <i class="fas fa-external-link-alt" aria-hidden></i>:

1. [Changing Between Spaces and Tabs in Sublime Text][css-tricks]
2. [Gnulib manual § 1.4.2][gnu-no-tab]

#### <i class="fas fa-ruler-vertical" aria-hidden></i> Set vertical ruler

71 72 73
Thanks to
[Ross Allen  <i class="fab fa-stack-overflow" aria-hidden></i>][soruler], it can
be done by adding `"rulers": [80]` in the User Settings.
Vincent Tam's avatar
Vincent Tam committed
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

### <i class="fas fa-puzzle-piece" aria-hidden></i> Plugins

Press `<C-S-p>` and type **Package Control** to see a list of available options.

#### <i class="fab fa-fonticons-fi" aria-hidden></i> Icon Fonts

<i class="fas fa-external-link-alt" aria-hidden></i>
[Icon Fonts -- Package Control][icon_fonts]

Sometimes useful.  I can get _some_ of the shortcut prefixes only.

#### <i class="fab fa-markdown" aria-hidden></i> Markdown Extended

<i class="fas fa-external-link-alt" aria-hidden></i>
[Markdown Extended -- Package Control][mdx]

Enables _some_ HTML-like autocompletion in [Markdown][md] and syntax
highlighting, say

- `p``<p></p>` for paragraphs
- `sp``<span></span>` for `span`
- `t``<table></table>` for tables
- `/` → complete tag

[stcsp]: http://docs.sublimetext.info/en/latest/extensibility/command_palette.html
[Vim]: http://www.vim.org
[css-tricks]: https://css-tricks.com/changing-spaces-tabs-sublime-text/
[Makefile]: https://www.gnu.org/software/make/manual/make.html#Rule-Introduction
[gnu-no-tab]: https://www.gnu.org/software/gnulib/manual/html_node/Indent-with-spaces-not-TABs.html
[icon_fonts]: https://packagecontrol.io/packages/Icon%20Fonts
[mdx]: https://packagecontrol.io/packages/Markdown%20Extended
106
[md]: https://daringfireball.net/projects/markdown/
107
[soruler]: http://stackoverflow.com/questions/9910143/ddg#11319526