mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-11-10 10:58:33 +03:00
commit
81f93ee950
28
extension.ts
28
extension.ts
@ -51,12 +51,36 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('extension.vim_w', () => handleKeyEvent("w"));
|
||||
vscode.commands.registerCommand('extension.vim_x', () => handleKeyEvent("x"));
|
||||
vscode.commands.registerCommand('extension.vim_y', () => handleKeyEvent("y"));
|
||||
vscode.commands.registerCommand('extension.vim_z', () => handleKeyEvent("z"));
|
||||
vscode.commands.registerCommand('extension.vim_z', () => handleKeyEvent("z"));
|
||||
|
||||
vscode.commands.registerCommand('extension.vim_A', () => handleKeyEvent("A"));
|
||||
vscode.commands.registerCommand('extension.vim_I', () => handleKeyEvent("I"));
|
||||
vscode.commands.registerCommand('extension.vim_O', () => handleKeyEvent("O"));
|
||||
|
||||
|
||||
vscode.commands.registerCommand('extension.vim_B', () => handleKeyEvent("B"));
|
||||
vscode.commands.registerCommand('extension.vim_C', () => handleKeyEvent("C"));
|
||||
vscode.commands.registerCommand('extension.vim_D', () => handleKeyEvent("D"));
|
||||
vscode.commands.registerCommand('extension.vim_E', () => handleKeyEvent("E"));
|
||||
vscode.commands.registerCommand('extension.vim_F', () => handleKeyEvent("F"));
|
||||
vscode.commands.registerCommand('extension.vim_G', () => handleKeyEvent("G"));
|
||||
vscode.commands.registerCommand('extension.vim_H', () => handleKeyEvent("H"));
|
||||
vscode.commands.registerCommand('extension.vim_J', () => handleKeyEvent("J"));
|
||||
vscode.commands.registerCommand('extension.vim_K', () => handleKeyEvent("K"));
|
||||
vscode.commands.registerCommand('extension.vim_L', () => handleKeyEvent("L"));
|
||||
vscode.commands.registerCommand('extension.vim_M', () => handleKeyEvent("M"));
|
||||
vscode.commands.registerCommand('extension.vim_N', () => handleKeyEvent("N"));
|
||||
vscode.commands.registerCommand('extension.vim_P', () => handleKeyEvent("P"));
|
||||
vscode.commands.registerCommand('extension.vim_Q', () => handleKeyEvent("Q"));
|
||||
vscode.commands.registerCommand('extension.vim_R', () => handleKeyEvent("R"));
|
||||
vscode.commands.registerCommand('extension.vim_S', () => handleKeyEvent("S"));
|
||||
vscode.commands.registerCommand('extension.vim_T', () => handleKeyEvent("T"));
|
||||
vscode.commands.registerCommand('extension.vim_U', () => handleKeyEvent("U"));
|
||||
vscode.commands.registerCommand('extension.vim_V', () => handleKeyEvent("V"));
|
||||
vscode.commands.registerCommand('extension.vim_W', () => handleKeyEvent("W"));
|
||||
vscode.commands.registerCommand('extension.vim_X', () => handleKeyEvent("X"));
|
||||
vscode.commands.registerCommand('extension.vim_Y', () => handleKeyEvent("Y"));
|
||||
vscode.commands.registerCommand('extension.vim_Z', () => handleKeyEvent("Z"));
|
||||
|
||||
vscode.commands.registerCommand('extension.vim_0', () => handleKeyEvent("0"));
|
||||
vscode.commands.registerCommand('extension.vim_1', () => handleKeyEvent("1"));
|
||||
vscode.commands.registerCommand('extension.vim_2', () => handleKeyEvent("2"));
|
||||
|
30
package.json
30
package.json
@ -32,6 +32,8 @@
|
||||
"keybindings": [
|
||||
{ "key": "Escape", "command": "extension.vim_esc", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+;", "command": "extension.vim_colon", "when": "editorTextFocus" },
|
||||
{ "key": ":", "command": "extension.vim_colon", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+;", "command": "extension.vim_colon", "when": "editorTextFocus" },
|
||||
{ "key": "space", "command": "extension.vim_space", "when": "editorTextFocus" },
|
||||
|
||||
{ "key": "a", "command": "extension.vim_a", "when": "editorTextFocus" },
|
||||
@ -45,7 +47,7 @@
|
||||
{ "key": "i", "command": "extension.vim_i", "when": "editorTextFocus" },
|
||||
{ "key": "j", "command": "extension.vim_j", "when": "editorTextFocus" },
|
||||
{ "key": "k", "command": "extension.vim_k", "when": "editorTextFocus" },
|
||||
{ "key": "l", "command": "extension.vim_l", "when": "editorTextFocus" },
|
||||
{ "key": "l", "command": "extension.vim_l", "when": "editorTextFocus" },
|
||||
{ "key": "m", "command": "extension.vim_m", "when": "editorTextFocus" },
|
||||
{ "key": "n", "command": "extension.vim_n", "when": "editorTextFocus" },
|
||||
{ "key": "o", "command": "extension.vim_o", "when": "editorTextFocus" },
|
||||
@ -62,8 +64,31 @@
|
||||
{ "key": "z", "command": "extension.vim_z", "when": "editorTextFocus" },
|
||||
|
||||
{ "key": "Shift+a", "command": "extension.vim_A", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+b", "command": "extension.vim_B", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+c", "command": "extension.vim_C", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+d", "command": "extension.vim_D", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+e", "command": "extension.vim_E", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+f", "command": "extension.vim_F", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+g", "command": "extension.vim_G", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+h", "command": "extension.vim_H", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+i", "command": "extension.vim_I", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+o", "command": "extension.vim_O", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+j", "command": "extension.vim_J", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+k", "command": "extension.vim_K", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+l", "command": "extension.vim_L", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+m", "command": "extension.vim_M", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+n", "command": "extension.vim_N", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+o", "command": "extension.vim_O", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+p", "command": "extension.vim_P", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+q", "command": "extension.vim_Q", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+r", "command": "extension.vim_R", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+s", "command": "extension.vim_S", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+t", "command": "extension.vim_T", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+u", "command": "extension.vim_U", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+v", "command": "extension.vim_V", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+w", "command": "extension.vim_W", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+x", "command": "extension.vim_X", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+y", "command": "extension.vim_Y", "when": "editorTextFocus" },
|
||||
{ "key": "Shift+z", "command": "extension.vim_Z", "when": "editorTextFocus" },
|
||||
|
||||
{ "key": "0", "command": "extension.vim_0", "when": "editorTextFocus" },
|
||||
{ "key": "1", "command": "extension.vim_1", "when": "editorTextFocus" },
|
||||
@ -80,6 +105,7 @@
|
||||
{ "key": "Ctrl+J", "command": "cursorDown", "when": "editorTextFocus" },
|
||||
{ "key": "Ctrl+K", "command": "cursorUp", "when": "editorTextFocus" },
|
||||
{ "key": "Ctrl+L", "command": "cursorRight", "when": "editorTextFocus" },
|
||||
|
||||
{ "key": "Ctrl+Shift+.", "command": "extension.showCmdLine", "when": "editorTextFocus" }
|
||||
]
|
||||
},
|
||||
|
@ -55,16 +55,18 @@ export default class InsertMode extends Mode {
|
||||
const position = editor.selection.active;
|
||||
|
||||
editor.edit(t => {
|
||||
t.insert(position, this.Translate(key));
|
||||
t.insert(position, this.ResolveKeyValue(key));
|
||||
});
|
||||
}
|
||||
|
||||
private Translate(raw : string) : string {
|
||||
switch (raw) {
|
||||
// Some keys have names that are different to their value.
|
||||
// TODO: we probably need to put this somewhere else.
|
||||
private ResolveKeyValue(key : string) : string {
|
||||
switch (key) {
|
||||
case 'space':
|
||||
return ' ';
|
||||
default:
|
||||
return raw;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@ export default class VisualMode extends Mode {
|
||||
}
|
||||
|
||||
ShouldBeActivated(key : string, currentMode : ModeName) : boolean {
|
||||
return (key === "v" || key === "V");
|
||||
// TODO: improve this logic for "V".
|
||||
return (key === "v" || key === "V") && (currentMode === ModeName.Command);
|
||||
}
|
||||
|
||||
HandleActivation(key : string) : void {
|
||||
|
Loading…
Reference in New Issue
Block a user