为什么要这么麻烦地配置VS Code呢?
1. 用过一阵子的nvim,那种coding的时候双手不离开而且几乎只要摸着“F”、"J"键,都能快速跳转,疯狂分屏的感觉,真的太爽了。
2. 但不继续用nvim的原因是,操作浏览器、多窗口什么的,其实还是需要用到鼠标。特别是分析代码、构思、查资料的时候,有个鼠标来引导视野还是需要的,这样感觉思维会没那么凌乱些。
3. 远程编辑、Git管理、文件目录管理等功能上,VS Code+插件 还是比 nvim+插件 要做的好。
4. 而我对编辑器启动速度也没有太大的需求,所以就配复杂点,来实现coding的时候双手不离开键盘吧。
配置思路
修改默认 ”Keyboard Shortcuts“
考虑到VS Code有很多有用的快捷键都注册了Ctrl+字母,那自己自定义的快捷键尽可能以:
Ctrl-Shift-${key} --- 后面简写为
Ctrl-k-${key} --- 后面简写为
原常用快捷键
新建标签:
下一行插入一行:
上一行插入一行:
替换:
全局替换:
查找:
全局查找:
撤销:
重做:
0. 编辑与文件操作切换
跳转到文件:
跳转到工作区的某一字符:
跳转到当前缓冲区:
跳转到文件目录:
1. 快速跳转
插件
- jumpy
0. 方向移动与行
上一个位置:
行首: / home
行末: / end
文首: /
文末: /
向上: / upArrow
向下: / downArrow
向左: / leftArrow
向右: / rightArrow
选中${方向}:
选中当前行:
1. 翻页:
上一页: / pageup
下一页: / pagedown
2. 快速定位跳转模式
跳转到:
行跳转:
单词跳转:
3. 单词跳转
选中当前单词:
单词左端:
单词右端:
单词向左选中:
单词向右选中:
2. 快速编辑
格式化:
左缩进:
右缩进:
折叠:
展开:
查看git文件变化:
打开terminal:
关闭terminal:
3. 快捷输入 snippets 配置
python snippets:
{
// https://code.visualstudio.com/docs/editor/userdefinedsnippets
"Finfo": {
"prefix": "Finfo",
"body": [
"# -*- coding: utf-8 -*-",
"# author: rodemon",
"# license: (C) Copyright 2018-2020, Corporation Limited.",
"# contact: [email protected]",
"# time: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
"# note:",
"\"\"\"",
"${1:Simple Explanation}",
"~~~~~",
"INFO: ${2:detailed informations}",
"\"\"\""
],
"description": "file informations"
},
"Cinfo": {
"prefix": "Cinfo",
"body": [
"\"\"\"",
"INFO: ${1:detailed informations}",
"",
"Payload:",
" @ ${2:varity}: ${3:info}",
" * ${4:method}: ${5:info}",
"\"\"\""
]
},
"funinfo": {
"prefix": "funinfo",
"body": [
"\"\"\"",
"Retn: ${1:type}",
"",
"Params",
":${2:type} ${3:name}: ${4:info}",
"",
"INFO: ${5:detailed informations}",
"\"\"\""
],
"description": "function infomations"
},
"cls": {
"prefix": "cls",
"body": [
"class ${1:name}(Object):",
"",
" def __init__(self, ${2:params}):",
" ${3:code}"
],
"description": "class ..."
}
}
配置
配置文件,替换原本的keybindings.json就可以用上面的快捷键了。
```json
// Empty
[
{
"key": "shift+",
"command": "extension.jumpy-exit"
},
{
"key": "ctrl+shift+'",
"command": "extension.jumpy-line"
},
{
"key": "ctrl+shift+;",
"command": "extension.jumpy-word"
},
{
"key": "ctrl+shift+n",
"command": "cursorPageDown",
"when": "textInputFocus"
},
{
"key": "pagedown",
"command": "cursorPageDown",
"when": "textInputFocus"
},
{
"key": "ctrl+j",
"command": "-workbench.action.togglePanel"
},
{
"key": "ctrl+shift+p",
"command": "cursorPageUp",
"when": "textInputFocus"
},
{
"key": "pageup",
"command": "cursorPageUp",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+w",
"command": "-workbench.action.closeWindow"
},
{
"key": "ctrl+right",
"command": "-cursorWordEndRight",
"when": "textInputFocus"
},
{
"key": "ctrl+left",
"command": "-cursorWordStartLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+backspace",
"command": "deleteWordLeft",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+backspace",
"command": "-deleteWordLeft",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+backspace",
"command": "deleteWordRight",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+delete",
"command": "-deleteWordRight",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+enter",
"command": "-markdown-preview-enhanced.runAllCodeChunks",
"when": "editorLangId == 'markdown'"
},
{
"key": "ctrl+shift+n",
"command": "-workbench.action.newWindow"
},
{
"key": "ctrl+shift+b",
"command": "cursorBottom",
"when": "textInputFocus"
},
{
"key": "ctrl+end",
"command": "cursorBottom",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+j",
"command": "cursorDown",
"when": "textInputFocus"
},
{
"key": "down",
"command": "cursorDown",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+j",
"command": "cursorDownSelect",
"when": "textInputFocus"
},
{
"key": "shift+down",
"command": "-cursorDownSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+end",
"command": "-cursorBottomSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+e",
"command": "cursorEnd",
"when": "textInputFocus"
},
{
"key": "end",
"command": "cursorEnd",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+e",
"command": "cursorEndSelect",
"when": "textInputFocus"
},
{
"key": "shift+end",
"command": "-cursorEndSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+q",
"command": "cursorHome",
"when": "textInputFocus"
},
{
"key": "home",
"command": "cursorHome",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+q",
"command": "cursorHomeSelect",
"when": "textInputFocus"
},
{
"key": "shift+home",
"command": "-cursorHomeSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+h",
"command": "cursorLeft",
"when": "textInputFocus"
},
{
"key": "left",
"command": "cursorLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+h",
"command": "cursorLeftSelect",
"when": "textInputFocus"
},
{
"key": "shift+left",
"command": "-cursorLeftSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+right",
"command": "-cursorWordEndRightSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+left",
"command": "-cursorWordStartLeftSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+o",
"command": "cursorWordPartRight"
},
{
"key": "ctrl+shift+i",
"command": "cursorWordPartLeft"
},
{
"key": "ctrl+k ctrl+i",
"command": "cursorWordPartLeftSelect"
},
{
"key": "ctrl+k ctrl+o",
"command": "cursorWordPartRightSelect"
},
{
"key": "ctrl+shift+o",
"command": "-workbench.action.gotoSymbol"
},
{
"key": "ctrl+k ctrl+n",
"command": "cursorPageDownSelect",
"when": "textInputFocus"
},
{
"key": "shift+pagedown",
"command": "-cursorPageDownSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+p",
"command": "cursorPageUpSelect",
"when": "textInputFocus"
},
{
"key": "shift+pageup",
"command": "-cursorPageUpSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+l",
"command": "cursorRight",
"when": "textInputFocus"
},
{
"key": "right",
"command": "cursorRight",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+l",
"command": "cursorRightSelect",
"when": "textInputFocus"
},
{
"key": "shift+right",
"command": "-cursorRightSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+t",
"command": "cursorTop",
"when": "textInputFocus"
},
{
"key": "ctrl+home",
"command": "cursorTop",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+t",
"command": "cursorTopSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+home",
"command": "-cursorTopSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+shift+k",
"command": "cursorUp",
"when": "textInputFocus"
},
{
"key": "up",
"command": "cursorUp",
"when": "textInputFocus"
},
{
"key": "ctrl+k ctrl+k",
"command": "cursorUpSelect",
"when": "textInputFocus"
},
{
"key": "shift+up",
"command": "-cursorUpSelect",
"when": "textInputFocus"
},
{
"key": "ctrl+left",
"command": "-cursorWordAccessibilityLeft",
"when": "accessibilityModeEnabled && textInputFocus"
},
{
"key": "ctrl+shift+left",
"command": "-cursorWordAccessibilityLeftSelect",
"when": "accessibilityModeEnabled && textInputFocus"
},
{
"key": "ctrl+right",
"command": "-cursorWordAccessibilityRight",
"when": "accessibilityModeEnabled && textInputFocus"
},
{
"key": "ctrl+shift+right",
"command": "-cursorWordAccessibilityRightSelect",
"when": "accessibilityModeEnabled && textInputFocus"
},
{
"key": "shift+escape",
"command": "-removeSecondaryCursors",
"when": "editorHasMultipleSelections && textInputFocus"
},
{
"key": "ctrl+r",
"command": "editor.action.startFindReplaceAction"
},
{
"key": "ctrl+h",
"command": "-editor.action.startFindReplaceAction"
},
{
"key": "ctrl+shift+h",
"command": "-workbench.action.replaceInFiles"
},
{
"key": "ctrl+'",
"command": "workbench.action.gotoLine"
},
{
"key": "ctrl+g",
"command": "-workbench.action.gotoLine"
},
{
"key": "ctrl+k ctrl+p",
"command": "-workbench.action.showAllEditors"
},
{
"key": "ctrl+shift+t",
"command": "-workbench.action.reopenClosedEditor"
},
{
"key": "ctrl+shift+,",
"command": "-editor.action.inPlaceReplace.up",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+[IntlBackslash]",
"command": "-editor.action.inPlaceReplace.down",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+.",
"command": "-editor.action.inPlaceReplace.down",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+1",
"command": "-editor.action.replaceOne",
"when": "editorFocus && findWidgetVisible"
},
{
"key": "ctrl+shift+1",
"command": "-search.action.replace",
"when": "matchFocus && replaceActive && searchViewletVisible"
},
{
"key": "ctrl+alt+enter",
"command": "-search.action.replaceAll",
"when": "replaceActive && searchViewletVisible && !findWidgetVisible"
},
{
"key": "ctrl+shift+1",
"command": "-search.action.replaceAllInFile",
"when": "fileMatchFocus && replaceActive && searchViewletVisible"
},
{
"key": "ctrl+shift+enter",
"command": "-search.action.replaceAllInFile",
"when": "fileMatchFocus && replaceActive && searchViewletVisible"
},
{
"key": "ctrl+shift+1",
"command": "-search.action.replaceAllInFolder",
"when": "folderMatchFocus && replaceActive && searchViewletVisible"
},
{
"key": "ctrl+shift+enter",
"command": "-search.action.replaceAllInFolder",
"when": "folderMatchFocus && replaceActive && searchViewletVisible"
},
{
"key": "ctrl+shift+r",
"command": "-editor.action.refactor",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+r",
"command": "-workbench.action.quickOpenNavigatePreviousInRecentFilesPicker",
"when": "inQuickOpen && inRecentFilesPicker"
},
{
"key": "ctrl+shift+r",
"command": "workbench.action.replaceInFiles"
},
{
"key": "ctrl+alt+enter",
"command": "search.action.replaceAll"
},
{
"key": "ctrl+shift+a",
"command": "search.action.replace"
},
{
"key": "ctrl+shift+i",
"command": "-editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+i",
"command": "-editor.action.formatDocument.none",
"when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorHasDocumentFormattingProvider && !editorReadonly"
},
{
"key": "ctrl+shift+w",
"command": "workbench.files.action.focusOpenEditorsView",
"when": "workbench.explorer.openEditorsView.active"
},
{
"key": "ctrl+k e",
"command": "-workbench.files.action.focusOpenEditorsView",
"when": "workbench.explorer.openEditorsView.active"
},
{
"key": "alt+n alt+n",
"command": "explorer.newFile"
},
{
"key": "alt+n alt+f",
"command": "explorer.newFolder"
},
{
"key": "ctrl+e",
"command": "workbench.view.explorer"
},
{
"key": "ctrl+shift+e",
"command": "-workbench.view.explorer"
},
{
"key": "ctrl+g",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl+e",
"command": "-workbench.action.quickOpen"
},
{
"key": "ctrl+shift+x",
"command": "workbench.action.addRootFolder"
},
{
"key": "ctrl+shift+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+x",
"command": "-workbench.view.extensions"
},
{
"key": "ctrl+t",
"command": "workbench.action.terminal.new"
},
{
"key": "ctrl+shift+`",
"command": "-workbench.action.terminal.new"
},
{
"key": "ctrl+shift+c",
"command": "-workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
},
{
"key": "ctrl+k ctrl+g",
"command": "workbench.action.showAllSymbols"
},
{
"key": "ctrl+t",
"command": "-workbench.action.showAllSymbols"
},
{
"key": "ctrl+shift+t",
"command": "workbench.action.closePanel",
"when": "terminalFocus"
},
{
"key": "ctrl+k ctrl+t",
"command": "-workbench.action.selectTheme"
},
{
"key": "ctrl+y",
"command": "-redo",
"when": "textInputFocus && !editorReadonly"
}
]