【VSCode】vscode-vim方案
【VSCode】vscode-vim方案
映射
- <A-e>
- <leader>ff
- <leader>ls
- <leader>gr
- <leader>,
- <leader>sc
- <leader>bd
- <leader>br
- <leader>bo
- <leader>bD
- <leader>bp
- <leader>bn
- <leader>yp
- <leader>yP
- <leader>yn
- <leader>yb
- <leader>pw
- <C-/>
- <leader>tf
- go
- gi
- gcc
- gh
- gt
- ngt
- gT
- <S>
- <S-Tab>
- |
- \
- 上下选择:alt + j/k
- 窗口移动:ctrl + hjkl
settings.json
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
{
// 设置相对行号
"editor.lineNumbers": "relative",
// 绑定vim前导键
"vim.leader": "<space>",
"vim.easymotion": false,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
// 按键映射
// 普通模式下的非递归按键绑定
"vim.normalModeKeyBindingsNonRecursive": [
// jump list跳转
{
"before": [
"g",
"o"
],
"after": [
"<C-o>"
]
},
{
"before": [
"g",
"i"
],
"after": [
"<C-i>"
]
},
{
"before": [
"leader",
"l",
"s"
],
"commands": [
"workbench.action.gotoSymbol"
]
},
{
"before": [
"<leader>",
"f",
"f"
],
"commands": [
"workbench.action.quickOpen"
],
},
{
"before": [
"<leader>",
"g",
"r"
],
"commands": [
"editor.action.goToReferences"
]
},
{
"before": [
"<leader>",
","
],
"commands": [
"workbench.action.showAllEditors"
]
},
{
"before": [
"<leader>",
"s",
"c"
],
"commands": [
"workbench.action.showCommands"
]
},
{
"before": [
"<leader>",
"b",
"d"
],
"commands": [
"workbench.action.closeActiveEditor"
]
},
{
"before": [
"<leader>",
"b",
"o"
],
"commands": [
"workbench.action.closeOtherEditors"
]
},
{
"before": [
"<leader>",
"b",
"r"
],
"commands": [
"workbench.action.closeEditorsToTheRight"
]
},
{
"before": [
"<leader>",
"b",
"D"
],
"commands": [
"workbench.action.closeEditorsInGroup"
]
},
{
"before": [
"<C-/>"
],
"commands": [
"workbench.action.terminal.toggleTerminal"
]
},
{
"before": [
"<leader>",
"t",
"f"
],
"commands": [
"workbench.action.terminal.openNativeConsole"
]
},
{
"before": [
"\\"
],
"commands": [
"workbench.action.splitEditorDown"
]
},
{
"before": [
"|"
],
"commands": [
"workbench.action.splitEditorToRightGroup"
]
},
{
"before": [
"<leader>",
"b",
"n"
],
"commands": [
"workbench.action.moveEditorToNextGroup"
]
},
{
"before": [
"<leader>",
"b",
"p"
],
"commands": [
"workbench.action.moveEditorToPreviousGroup"
]
},
{
"before": [
"<leader>",
"y",
"p"
],
"commands": [
{
"command": "copyRelativeFilePath",
"args": []
}
]
},
// 拷贝绝对路径
{
"before": [
"<leader>",
"y",
"P"
],
"commands": [
{
"command": "copyFilePath",
"args": []
}
]
},
{
"before": [
"<leader>",
"y",
"n"
],
"commands": [
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "echo '${fileBasename}' | clip\n"
}
}
]
},
{
"before": [
"<leader>",
"p",
"w"
],
"after": [
"v",
"i",
"w",
"p"
]
},
{
"before": [
"<leader>",
"y",
"b"
],
"commands": [
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "git branch --show-current | tr -d '\\n' | clip\n"
}
}
]
}
],
// 插入模式下的非递归按键绑定
"vim.insertModeKeyBindings": [
{
"before": [
"j",
"j"
],
"after": [
"<Esc>"
]
}
],
// 命令模式下的非递归按键绑定
"vim.commandLineModeKeyBindingsNonRecursive": [],
// 可视模式下的非递归按键绑定
"vim.operatorPendingModeKeyBindings": [],
// 下面定义的按键将交由vscode进行处理,而不是vscode-vim插件
"vim.handleKeys": {
"<C-c>": false,
"<C-v>": false,
"<C-f>": false,
"<C-x>": false,
"<C-a>": false,
"<C-z>": false,
"<C-y>": false,
"<C-r>": true,
},
// <C-c>
// <A-f>
// <Esc>
}
keybindings.json
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
[
// Navigation
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight"
},
{
"key": "ctrl+k",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+j",
"command": "workbench.action.navigateDown"
},
{
"key": "alt+e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.files.action.focusFilesExplorer"
]
},
"when": "isWindows && vim.mode == 'Normal' && (editorTextFocus || !inputFocus) && !sideBarFocus"
},
{
"key": "alt+e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.action.focusActiveEditorGroup"
]
},
"when": "isWindows && sideBarFocus && !inputFocus"
},
{
"key": "alt+e",
"when": "isWindows && vim.mode == 'Normal' && editorTextFocus && foldersViewVisible",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "cmd+e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.files.action.focusFilesExplorer"
]
},
"when": "isMac && vim.mode == 'Normal' && (editorTextFocus || !inputFocus) && !sideBarFocus"
},
{
"key": "cmd+e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.action.focusActiveEditorGroup"
]
},
"when": "isMac && sideBarFocus && !inputFocus"
},
{
"key": "cmd+e",
"when": "isMac && vim.mode == 'Normal' && editorTextFocus && foldersViewVisible",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "tab",
"command": "workbench.action.nextEditorInGroup",
"when": "(vim.mode == 'Normal' || vim.mode == 'Visual') && editorTextFocus"
},
{
"key": "shift+tab",
"command": "workbench.action.previousEditorInGroup",
"when": "(vim.mode == 'Normal' || vim.mode == 'Visual') && editorTextFocus"
},
{
"key": "tab",
"command": "tab",
"when": "vim.mode == 'Insert' && editorTextFocus"
},
// coding
{
"key": "alt+j",
"command": "workbench.action.quickOpenSelectNext",
"when": "isWindows && inQuickOpen"
},
{
"key": "alt+k",
"command": "workbench.action.quickOpenSelectPrevious",
"when": "isWindows && inQuickOpen"
},
{
"key": "cmd+j",
"command": "workbench.action.quickOpenSelectNext",
"when": "isMac && inQuickOpen"
},
{
"key": "cmd+k",
"command": "workbench.action.quickOpenSelectPrevious",
"when": "isMac && inQuickOpen"
},
// File Explorer
{
"key": "r",
"command": "renameFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "y",
"command": "filesExplorer.copy",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "p",
"command": "filesExplorer.paste",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "x",
"command": "filesExplorer.cut",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "d",
"command": "deleteFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "a",
"command": "explorer.newFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "shift-a",
"command": "explorer.newFolder",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "enter",
"command": "explorer.openAndPassFocus",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceIsFolder && !inputFocus"
},
{
"key": "f8",
"command": "highlight.selectedWords"
},
{
"key": "shift+f8",
"command": "-highlight.selectedWords"
},
// 终端按键
{
"key": "ctrl+/",
"command": "workbench.action.terminal.toggleTerminal",
}
]
This post is licensed under
CC BY 4.0
by the author.