From d45e866643b6e24f36d73cef15681603a6e555c2 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 26 Jun 2018 19:13:38 -0700 Subject: [PATCH 1/2] Allow for quickpick commandline usage --- README.md | 19 +++++++++++++++++++ extension.ts | 8 ++++++++ package.json | 4 ++++ src/cmd_line/commandLine.ts | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/README.md b/README.md index 69352d99153..ab05f1fa2c9 100644 --- a/README.md +++ b/README.md @@ -597,6 +597,25 @@ Are you on a Mac? Did you go through our [mac-setup](#mac-setup) instructions? Press `shift+` to close all of those boxes. +### How can I use the commandline when in Zen mode or when the status bar is disabled? + +This extension registers a command pallete of visual studio code exists to show a quickpick version of the commandline. This can be remapped as follows in visual studio keybindings.json settings file. +``` +{ + "key": "shift+;", + "command": "vim.showQuickpickCmdLine", + "when": "editorTextFocus && vim.mode != 'Insert'" +} +``` +Or for Zen mode only: +``` +{ + "key": "shift+;", + "command": "vim.showQuickpickCmdLine", + "when": "inZenMode && vim.mode != 'Insert'" +} +``` + ## Contributing This project is maintained by a group of awesome [people](https://github.com/VSCodeVim/Vim/graphs/contributors) and contributions are extremely welcome :heart:. For a quick tutorial on how you can help, see our [contributing guide](/.github/CONTRIBUTING.md). diff --git a/extension.ts b/extension.ts index af374560219..ea170186232 100644 --- a/extension.ts +++ b/extension.ts @@ -196,6 +196,14 @@ export async function activate(context: vscode.ExtensionContext) { }); // register extension commands + registerCommand(context, 'vim.showQuickpickCmdLine', async () => { + let [modeHandler] = await ModeHandlerMap.getOrCreate( + new EditorIdentity(vscode.window.activeTextEditor).toString() + ); + commandLine.PromptAndRun('', modeHandler.vimState); + modeHandler.updateView(modeHandler.vimState); + }); + registerCommand(context, 'vim.remap', async (args: ICodeKeybinding) => { taskQueue.enqueueTask(async () => { const mh = await getAndUpdateModeHandler(); diff --git a/package.json b/package.json index e26b166224a..8ce008ffb6e 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,10 @@ { "command": "toggleVim", "title": "Vim: Toggle Vim Mode" + }, + { + "command": "vim.showQuickpickCmdLine", + "title": "Vim: Show Command Line" } ], "keybindings": [ diff --git a/src/cmd_line/commandLine.ts b/src/cmd_line/commandLine.ts index 1e93c1d2eca..fa9d344cb2f 100644 --- a/src/cmd_line/commandLine.ts +++ b/src/cmd_line/commandLine.ts @@ -77,6 +77,24 @@ class CommandLine { } } + public async PromptAndRun(initialText: string, vimState: VimState): Promise { + if (!vscode.window.activeTextEditor) { + logger.debug('commandLine : No active document'); + return; + } + let cmd = await vscode.window.showInputBox(this.getInputBoxOptions(initialText)); + await this.Run(cmd!, vimState); + } + + private getInputBoxOptions(text: string): vscode.InputBoxOptions { + return { + prompt: 'Vim command line', + value: text, + ignoreFocusOut: false, + valueSelection: [text.length, text.length], + }; + } + public async ShowHistory(initialText: string, vimState: VimState): Promise { if (!vscode.window.activeTextEditor) { logger.debug('commandLine : No active document.'); From df2717cce6eca9fdf4e6d696f08b9ba8f2f621f8 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Tue, 3 Jul 2018 15:03:48 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index e851efc3144..09613b70403 100644 --- a/README.md +++ b/README.md @@ -585,7 +585,7 @@ Press `shift+` to close all of those boxes. ### How can I use the commandline when in Zen mode or when the status bar is disabled? -This extension exposes a remappable command to show a quickpick version of the commandline. This can be remapped as follows in visual studio keybindings.json settings file. +This extension exposes a remappable command to show a vscode style quick-pick, limited functionality, version of the commandline. This can be remapped as follows in visual studio keybindings.json settings file. ``` { "key": "shift+;", @@ -604,7 +604,6 @@ Or for Zen mode only: ## ❤️ Contributing - This project is maintained by a group of awesome [people](https://github.com/VSCodeVim/Vim/graphs/contributors) and contributions are extremely welcome :heart:. For a quick tutorial on how you can help, see our [contributing guide](/.github/CONTRIBUTING.md). ### Special shoutouts to cool contributors