VS Code
Visual Studio Code
Быстрые клавши
См. также:
- быстрые клавиши Sublime Text
- Sam Selikoff
- Emmet commands and keybindings - VS Code extension
Интерфейс | |
| Показать/спрятать SideBar | Ctrl+B |
| Переключиться на SideBar и обратно | Ctrl+0 (#Key Bindings) |
| Переключиться на SideBar с фокусом на активном файле | Shift+Alt+L (#Key Bindings) |
| Свернуть папки в SideBar | [ (#Key Bindings) |
| Показать/спрятать Terminal | Ctrl+` |
| Открыть внешний Terminal | Ctrl+Shift+C |
Переходы | |
| Перейти к переменной | F12 |
| Перейти к парной скобке | Ctrl+Shift+\ |
| Перейти к парному тегу | Ctrl+Shift+5 (#Key Bindings) |
| Previous edit point | Alt+< (Emmet commands and keybindings) |
| Next edit point | Alt+> (Emmet commands and keybindings) |
Выделение текста | |
| Smart Select | Shift+Alt+→ |
| Previous item | Ctrl+Alt+< (Emmet commands and keybindings) |
| Next item | Ctrl+Alt+> (Emmet commands and keybindings) |
| Выделить тег (или текст внутри тега) | Ctrl+Shift+A (Emmet commands and keybindings) |
HTML | |
| Обернуть тэгом | Alt+E W (Emmet commands and keybindings) Alt+W (#Key Bindings) |
| Переименовать тег | Alt+E R (Emmet commands and keybindings) |
| Удалить тег | Alt+E D (Emmet commands and keybindings) |
Обернуть в <strong> |
Ctrl+Alt+S (#Key Bindings) |
Вставить <br> |
Ctrl+Shift+Enter (#Key Bindings) |
Вставить |
Ctrl+Shift+Space (#Key Bindings) |
| Выстроить тег в одну строку (Merge) | Alt+E M (Emmet commands and keybindings) |
| Закомментировать | Ctrl+/ |
| Toggle comment (HTML only) | Alt+E Alt+/(Emmet commands and keybindings) |
Прочее | |
Переключение слов: true/false, yes/no, on/off, 0/1,left/right, top/bottom, up/down, width/height |
Alt+R (Toggler) |
| Дублировать строку | Ctrl+Alt+Shift+↑, ↓ на NumPad |
| Переименовать переменную | F2 |
| Посчитать математическое выражение (demo) |
Alt+E = (Emmet commands and keybindings) |
Настройки
Twig
Чтобы работало автодополнение HTML тэгов в файлах .twig: Settings → поиск Emmet. Найти секцию Emmet: Include languages и добавить:
- Item : twig
- Value : html
Auto Rename Tag
Ctrl+Shift+P — Preferences: open settings (JSON) — в settings.json добавить строку:
"editor.linkedEditing": true,
Key Bindings
Ctrl+Shift+P — найти команду Preferences: Open Keyboard Shortcuts (JSON) (это файл keybindings.json)
Focus toggle between editor and sidebar
Ctrl+0
Shift+Alt+L
// Unbind unconditional default
{ "key": "ctrl+0", "command": "-workbench.action.focusSideBar" },
// to ←
{ "key": "ctrl+0", "command": "workbench.action.focusSideBar", "when": "!sideBarFocus" },
// from →
{ "key": "ctrl+0", "command": "workbench.action.focusActiveEditorGroup", "when": "sideBarFocus" },
// Show current file in sidebar explorer with focus
{ "key": "shift+alt+l", "command": "workbench.files.action.focusFilesExplorer", "when": "editorTextFocus" },
Collapse Explorer Folders
[
{
"key": "[",
"command": "workbench.files.action.collapseExplorerFolders",
"when": "explorerViewletFocus && !inputFocus"
}
Перейти к парному тегу
Ctrl+Shift+5
// Перейти к парному тегу
{
"key": "ctrl+shift+5",
"command": "editor.emmet.action.matchTag",
"when": "editorTextFocus && !inDebugRepl"
},
Wrap selected text within a HTML tag
Alt+W
// Wrap selected text within a HTML tag by Alt+W
{
"key": "alt+w",
"command": "editor.emmet.action.wrapWithAbbreviation",
"when": "editorHasSelection && editorTextFocus"
},
Wrap strong
Ctrl+Alt+S
// Wrap <strong> by Ctrl+Alt+S
{
"key": "ctrl+alt+s",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"langId": "html",
"name": "<strong>"
}
},
Insert <br>
Ctrl+Shift+Enter
// Insert <br> by Ctrl+Shift+Enter
{
"key": "ctrl+shift+enter",
"command": "type",
"args": {
"text": "<br>"
},
"when": "editorTextFocus"
},
Insert nbsp;
Ctrl+Shift+Space
// Insert by Ctrl+Shift+Space
{ "key": "ctrl+shift+space", "command": "type", "args": { "text": " " }, "when": "editorTextFocus" },
Сниппеты
Ctrl+Shift+P — snippet — Preferences: Configure User Snippets — выбрать подходящий расширению файл и добавить в него код из генератора сниппетов:
В поле Tab trigger... вписать буквосочетание-префикс, по набору которого и нажатию Tab будет вставляться сниппет.
Чтобы префикс срабатывал при ошибочном наборе на кириллице, нужно вписать его в виде массива:
"prefix": ["date", "вфеу"],
Тэг <а href...> по букве ф
"a href кириллицей": {
"prefix": ["ф"],
"body": [
"<a href=\"${1}\">${1}</a>"
],
"description": "a href"
},
Тэг <strong> по клавише ы
Сначала в Ctrl+Shift+P — snippet — Preferences: Configure User Snippets вставить снипепет для вставки тэга по нажатию клавиши ы:
"<strong>": {
"prefix": "ы",
"body": [
"<strong>${TM_SELECTED_TEXT}${1}</strong>"
],
"description": "Wrap <strong>"
}
Затем в User > keybinding.json добавить вызов этого сниппета по хоткею Ctrl+Alt+s:
{
"key": "ctrl+alt+s",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"langId": "html",
"name": "<strong>"
}
}
Replace Rules
Экстеншен Replace Rules позволяет задать несколько правил поиска и замены и выполнить их за один раз.
Форматирование литературного текста, удаление Sizzy Online Custom Elements
Ctrl+Shift+P — Preferences: open settings (JSON) — в settings.json добавляем:
"replacerules.rules": {
"Строки текста обернуть в тег <p>": {
"find": "^(?![\\s\\n<])(.*)$",
"replace": "<p>$1</p>"
},
"Абзацы, заголовки, списки - с новой строки": {
"find": "([^\r\n])(<p>|<h[1-5]>|<br>|<li>|<div)",
"replace": "$1\n$2"
},
"Убрать переводы строк перед заголовками": {
"find": "(<p>\\s*|<br>\\s*)(<h\\d>)",
"replace": "$2"
},
"Remove trailing spaces": {
"find": "[ \t]+$",
"replace": ""
},
"Close p tags": {
"find": "<p>(.+[^(</p>\\s*)])\\n",
"replace": "<p>$1</p>\n"
},
"Дефис в длинное тире": {
"find": "([ >,.;…\n\r\t])[-–]([ …\n\t])",
"replace": "$1—$2"
},
"Кавычки": {
//"find": "(\\s|\\n|\\t)"((.|\n)+?)"",
"find": "(\\s|\\n|\\t|>| |\\()("|«)((.|\\n)+?[^\\s\\n\\t]*)("|»)",
"replace": "$1«$3»"
},
"Троеточия": {
"find": "\\.\\.\\.",
"replace": "…"
},
"H3 to H2": {
"find": "<h3>((.|\n)+?)</h3>",
"replace": "<h2>$1</h2>"
},
"H4 to H3": {
"find": "<h4>((.|\n)+?)</h4>",
"replace": "<h3>$1</h3>"
},
"Sizzy - remove Online Custom Elements": {
"find": "sizzy-\\w+-\\d *",
"replace": ""
}
},
"replacerules.rulesets": {
"Форматирование литературного текста": {
"rules": [
"Remove trailing spaces",
"Дефис в длинное тире",
"Кавычки",
"Троеточия"
]
}
},
Ctrl+Shift+P — Preferences: Open Keyboard Shortcuts (JSON) — в keybiddings.json добавляем:
{ // Replace Rules — Форматирование литературного текста
"key": "ctrl+shift+]",
"command": "replacerules.runRuleset",
"when": "editorTextFocus && !editorReadonly",
"args": {
"rulesetName": "Форматирование литературного текста"
}
}
Вызывать команду или комбинацией Ctrl+Alt+R и выбором отдельных правил, или настроенной комбинацией Ctrl+Shift+]