From e8039f519555438198ed8e32f492e2ae9b477c6a Mon Sep 17 00:00:00 2001 From: Ayslan Fontes Date: Wed, 25 Jun 2025 19:22:43 -0300 Subject: [PATCH 1/3] Implement HelpCommand and integrate it into the exCommandParser --- src/cmd_line/commands/help.ts | 31 +++++++++++++++++++++++++++++++ src/vimscript/exCommandParser.ts | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/cmd_line/commands/help.ts diff --git a/src/cmd_line/commands/help.ts b/src/cmd_line/commands/help.ts new file mode 100644 index 00000000000..b1f1e5f57d5 --- /dev/null +++ b/src/cmd_line/commands/help.ts @@ -0,0 +1,31 @@ +import { ExCommand } from '../../vimscript/exCommand'; +import { VimState } from '../../state/vimState'; +import { window, ViewColumn } from 'vscode'; + +export class HelpCommand extends ExCommand { + async execute(_vimState: VimState): Promise { + const panel = window.createWebviewPanel('vimHelp', 'Help Vim', ViewColumn.Active, { + enableScripts: false, + }); + + panel.webview.html = ` + + +

Vim Help for VSCode

+ Basic Commands:
+ :w Save file
+ :q Quit editor
+ :wq Save and quit
+ :help Show this help
+
+ Movement:
+ h, j, k, l Move cursor
+ gg Go to start of file
+ G Go to end of file
+
+ And much more! See the documentation for details. + + + `; + } +} diff --git a/src/vimscript/exCommandParser.ts b/src/vimscript/exCommandParser.ts index 667ea8d8a98..4dfb2c7ff45 100644 --- a/src/vimscript/exCommandParser.ts +++ b/src/vimscript/exCommandParser.ts @@ -54,6 +54,7 @@ import { nameAbbrevParser } from './parserUtils'; import { LetCommand, UnletCommand } from '../cmd_line/commands/let'; import { CallCommand, EvalCommand } from '../cmd_line/commands/eval'; import { PwdCommand } from '../cmd_line/commands/pwd'; +import { HelpCommand } from '../cmd_line/commands/help'; type ArgParser = Parser; @@ -253,7 +254,7 @@ export const builtinExCommands: ReadonlyArray<[[string, string], ArgParser | und [['grepa', 'dd'], undefined], [['gu', 'i'], undefined], [['gv', 'im'], undefined], - [['h', 'elp'], undefined], + [['h', 'elp'], succeed(new HelpCommand())], [['ha', 'rdcopy'], undefined], [['helpc', 'lose'], undefined], [['helpg', 'rep'], undefined], From 9f4805e711f9a6ee4695bf5a98e508a562abb410 Mon Sep 17 00:00:00 2001 From: Ayslan Fontes Date: Wed, 25 Jun 2025 20:07:10 -0300 Subject: [PATCH 2/3] Update HelpCommand to enhance help content and add index.html for debugging --- src/cmd_line/commands/help.ts | 104 ++++++++++++++++++++++++++----- src/cmd_line/commands/index.html | 91 +++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 17 deletions(-) create mode 100644 src/cmd_line/commands/index.html diff --git a/src/cmd_line/commands/help.ts b/src/cmd_line/commands/help.ts index b1f1e5f57d5..3cdeb523f51 100644 --- a/src/cmd_line/commands/help.ts +++ b/src/cmd_line/commands/help.ts @@ -9,23 +9,93 @@ export class HelpCommand extends ExCommand { }); panel.webview.html = ` - - -

Vim Help for VSCode

- Basic Commands:
- :w Save file
- :q Quit editor
- :wq Save and quit
- :help Show this help
-
- Movement:
- h, j, k, l Move cursor
- gg Go to start of file
- G Go to end of file
-
- And much more! See the documentation for details. - - + + + +
+            VsCodeVim - Main Help
+
+      This is the main help file for the Vim emulator for Visual Studio Code.
+      You can find more information at: https://github.com/VSCodeVim/Vim
+									 k
+      Move around:  Use the cursor keys, or "h" to go left,	       h   l
+		    "j" to go down, "k" to go up, "l" to go right.	 j
+      Close this window:  Use ":q <ESC> ".
+
+     Modes:
+        Normal mode:    Press <ESC> to enter. Navigate and run commands.
+        Insert mode:    Press "i" to insert text. Press <ESC> to return to Normal mode.
+        Visual mode:    Press "v" to select text. Use movement keys to expand the selection.
+
+      Basic Commands:
+        :q        Quit
+        :w        Save
+        :wq       Save and quit
+        :qa!      Quit all without saving
+
+      Editing:
+        dd        Delete line
+        yy        Yank (copy) line
+        p         Paste below
+        u         Undo
+        Ctrl+r    Redo
+        x         Delete character under cursor
+        r<char>   Replace character under cursor
+        cw        Change word
+        ci"       Change inside quotes
+        caw       Change a word (including whitespace)
+        .         Repeat last change
+
+      Navigation:
+        gg        Go to the first line
+        G         Go to the last line
+        0         Go to the start of the line
+        $         Go to the end of the line
+        w         Jump to the start of the next word
+        b         Jump to the start of the previous word
+        Ctrl+d    Scroll down half a page
+        Ctrl+u    Scroll up half a page
+
+      Visual Mode:
+        v         Start visual mode (characterwise)
+        V         Start visual line mode
+        Ctrl+v    Start visual block mode
+
+      Registers & Macros:
+        "*p       Paste from system clipboard
+        q<letter>  Start recording a macro
+        @<letter>  Play macro
+
+      Buffers & Tabs:
+        :bn       Next buffer
+        :bp       Previous buffer
+        :bd       Delete buffer
+        :tabnew   Open new tab
+        gt        Next tab
+        gT        Previous tab
+
+      Search:
+        /pattern  Search forward for a pattern
+        ?pattern  Search backward for a pattern
+        n         Repeat search in the same direction
+        N         Repeat search in the opposite direction
+        :noh      Clear search highlighting
+
+      Miscellaneous:
+        :%s/old/new/g             Replace all occurrences in file
+        :set number               Show line numbers
+        :set relativenumber       Show relative line numbers
+        :help <command>           Show help for a command
+
+      Note:
+        You can replace or customize most keybinds.
+        For instructions, see: https://github.com/VSCodeVim/Vim#Settings
+
+      For more help, see the project repository or the official Vim guide.
+      
+ + + `; } } diff --git a/src/cmd_line/commands/index.html b/src/cmd_line/commands/index.html new file mode 100644 index 00000000000..fd0708a3341 --- /dev/null +++ b/src/cmd_line/commands/index.html @@ -0,0 +1,91 @@ + + + + +
+            VsCodeVim - Main Help
+
+      This is the main help file for the Vim emulator for Visual Studio Code.
+      You can find more information at: https://github.com/VSCodeVim/Vim
+									 k
+      Move around:  Use the cursor keys, or "h" to go left,	       h   l
+		    "j" to go down, "k" to go up, "l" to go right.	 j
+      Close this window:  Use ":q <ESC> ".
+
+     Modes:
+        Normal mode:    Press <ESC> to enter. Navigate and run commands.
+        Insert mode:    Press "i" to insert text. Press <ESC> to return to Normal mode.
+        Visual mode:    Press "v" to select text. Use movement keys to expand the selection.
+
+      Basic Commands:
+        :q        Quit
+        :w        Save
+        :wq       Save and quit
+        :qa!      Quit all without saving
+
+      Editing:
+        dd        Delete line
+        yy        Yank (copy) line
+        p         Paste below
+        u         Undo
+        Ctrl+r    Redo
+        x         Delete character under cursor
+        r<char>   Replace character under cursor
+        cw        Change word
+        ci"       Change inside quotes
+        caw       Change a word (including whitespace)
+        .         Repeat last change
+
+      Navigation:
+        gg        Go to the first line
+        G         Go to the last line
+        0         Go to the start of the line
+        $         Go to the end of the line
+        w         Jump to the start of the next word
+        b         Jump to the start of the previous word
+        Ctrl+d    Scroll down half a page
+        Ctrl+u    Scroll up half a page
+
+      Visual Mode:
+        v         Start visual mode (characterwise)
+        V         Start visual line mode
+        Ctrl+v    Start visual block mode
+
+      Registers & Macros:
+        "*p       Paste from system clipboard
+        q<letter>  Start recording a macro
+        @<letter>  Play macro
+
+      Buffers & Tabs:
+        :bn       Next buffer
+        :bp       Previous buffer
+        :bd       Delete buffer
+        :tabnew   Open new tab
+        gt        Next tab
+        gT        Previous tab
+
+      Search:
+        /pattern  Search forward for a pattern
+        ?pattern  Search backward for a pattern
+        n         Repeat search in the same direction
+        N         Repeat search in the opposite direction
+        :noh      Clear search highlighting
+
+      Miscellaneous:
+        :%s/old/new/g             Replace all occurrences in file
+        :set number               Show line numbers
+        :set relativenumber       Show relative line numbers
+        :help <command>           Show help for a command
+
+      Note:
+        You can replace or customize most keybinds.
+        For instructions, see: https://github.com/VSCodeVim/Vim#Settings
+
+      For more help, see the project repository or the official Vim guide.
+      
+ + + \ No newline at end of file From 2de6424e3cf4f13cb3419015f786e2472f971bdd Mon Sep 17 00:00:00 2001 From: Ayslan Fontes Date: Wed, 25 Jun 2025 20:14:11 -0300 Subject: [PATCH 3/3] fixes #9128 --- src/cmd_line/commands/help.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cmd_line/commands/help.ts b/src/cmd_line/commands/help.ts index 3cdeb523f51..009a15a8034 100644 --- a/src/cmd_line/commands/help.ts +++ b/src/cmd_line/commands/help.ts @@ -10,7 +10,6 @@ export class HelpCommand extends ExCommand { panel.webview.html = ` -
             VsCodeVim - Main Help
@@ -94,7 +93,6 @@ export class HelpCommand extends ExCommand {
       For more help, see the project repository or the official Vim guide.
       
- `; }