-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: Automatically start in Insert mode for specific schemes #9854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: Automatically start in Insert mode for specific schemes #9854
Conversation
|
|
||
| if ( | ||
| const isEditorChange = | ||
| forceSyncAndUpdate || |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| // 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); | ||
| } | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
What this PR does / why we need it:
This PR adds a new configuration option
vim.startInInsertModeSchemesthat allows users to specify document URI schemes that should automatically start in Insert mode.Use Cases
commentscheme. Users typically want to immediately start typing without pressingifirst.vscode-notebook-cellscheme. This provides a better experience when editing cells.gitlensscheme.Configuration Example
{
"vim.startInInsertModeSchemes": ["comment", "vscode-notebook-cell"]
}
Implementation Details
startInInsertModesetting is preserved and works alongside this new featureWhich 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:
editor.document.uri.schemewhich is a stable VS Code API[], so existing users are not affectedtest/testConfiguration.tsto include the new propertyyarn test