Skip to content

Commit 18b6457

Browse files
feat: Automatically start in Insert mode for specific schemes (#9854)
Refs #8782
1 parent fd2b7e8 commit 18b6457

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,16 @@
813813
"type": "boolean",
814814
"description": "Start in Insert mode."
815815
},
816+
"vim.startInInsertModeSchemes": {
817+
"type": "array",
818+
"items": {
819+
"type": "string"
820+
},
821+
"default": [
822+
"comment"
823+
],
824+
"markdownDescription": "List of document URI schemes that should automatically start in Insert mode. For example, use `[\"comment\"]` for GitHub PR comment editors, or `[\"comment\", \"gitlens\"]` for multiple schemes."
825+
},
816826
"vim.handleKeys": {
817827
"type": "object",
818828
"description": "Delegate certain key combinations back to VS Code to be handled natively.",

src/configuration/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class Configuration implements IConfiguration {
317317

318318
startInInsertMode = false;
319319

320+
startInInsertModeSchemes: string[] = ['comment'];
321+
320322
statusBarColorControl = false;
321323

322324
statusBarColors: IModeSpecificStrings<string | string[]> = {

src/configuration/iconfiguration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ export interface IConfiguration {
243243
*/
244244
startInInsertMode: boolean;
245245

246+
/**
247+
* List of document URI schemes that should automatically start in Insert mode.
248+
* For example, ['comment'] for GitHub PR comment editors.
249+
*/
250+
startInInsertModeSchemes: string[];
251+
246252
/**
247253
* Enable changing of the status bar color based on mode
248254
*/

src/mode/modeHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
106106
): Promise<ModeHandler> {
107107
const modeHandler = new ModeHandler(handlerMap, textEditor);
108108
await modeHandler.vimState.load();
109-
await modeHandler.setCurrentMode(configuration.startInInsertMode ? Mode.Insert : Mode.Normal);
109+
110+
// Check if this editor's URI scheme should start in Insert mode
111+
const scheme = textEditor.document.uri.scheme;
112+
const shouldStartInsert =
113+
configuration.startInInsertMode || configuration.startInInsertModeSchemes.includes(scheme);
114+
115+
await modeHandler.setCurrentMode(shouldStartInsert ? Mode.Insert : Mode.Normal);
110116
modeHandler.syncCursors();
111117
return modeHandler;
112118
}

test/testConfiguration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class Configuration implements IConfiguration {
7474
incsearch = true;
7575
inccommand = '' as const;
7676
startInInsertMode = false;
77+
startInInsertModeSchemes = ['comment'];
7778
statusBarColorControl = false;
7879
statusBarColors: IModeSpecificStrings<string | string[]> = {
7980
normal: ['#8FBCBB', '#434C5E'],

0 commit comments

Comments
 (0)