Skip to content

Conversation

@astron8t-voyagerx
Copy link

@astron8t-voyagerx astron8t-voyagerx commented Dec 5, 2025

What this PR does / why we need it:

This PR adds a new configuration option vim.startInInsertModeSchemes that allows users to specify document URI schemes that should automatically start in Insert mode.

Use Cases

  • GitHub PR Comments: Comment editors use the comment scheme. Users typically want to immediately start typing without pressing i first.
  • Jupyter Notebooks: Notebook cells use the vscode-notebook-cell scheme. This provides a better experience when editing cells.
  • GitLens commit messages: Uses the gitlens scheme.

Configuration Example

{
"vim.startInInsertModeSchemes": ["comment", "vscode-notebook-cell"]
}

Implementation Details

  • When a new editor is created with a matching URI scheme, it starts in Insert mode
  • When focus changes to an existing editor with a matching scheme, it automatically switches to Insert mode
  • The existing startInInsertMode setting is preserved and works alongside this new feature

Which issue(s) this PR fixes

This PR partially addresses #8782 by providing a flexible way for users to customize Vim behavior for specific contexts like Jupyter notebooks and comment editors.

While #8782 requested the ability to disable Vim for certain contexts, this PR takes a complementary approach: instead of disabling Vim entirely, it allows automatically entering Insert mode for specific URI schemes. This provides a better UX for contexts where users primarily want to type text (comments, notebook cells, etc.) while still maintaining Vim functionality when needed.

Special notes for your reviewer:

  • The implementation uses editor.document.uri.scheme which is a stable VS Code API
  • Default value is an empty array [], so existing users are not affected
  • I've also updated test/testConfiguration.ts to include the new property
  • I've run yarn test


if (
const isEditorChange =
forceSyncAndUpdate ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like forceSyncAndUpdate should be part of the if on line 50, not as part of isEditorChange

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad! Fixed.

extensionBase.ts Outdated
Comment on lines 58 to 65
// For existing editors (not newly created), check if we should switch to Insert mode
// based on the document's URI scheme when focus changes to this editor
if (!isNew && isEditorChange) {
const scheme = activeTextEditor.document.uri.scheme;
if (configuration.startInInsertModeSchemes.includes(scheme)) {
await curHandler.vimState.setCurrentMode(Mode.Insert);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting certain types of editors in Insert mode makes sense, but I'm skeptical of moving to Insert mode when focus changes. If that's the case, shouldn't we also enter Normal mode on focus changes for other editor types?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. If someone has changed the mode in an editor, it should be preserved. I've removed this logic so that this setting only takes effect when a new editor is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants