Basic setup
Follow these steps to create a working CodeMirror editor with Vim keybindings.Complete example
Here’s a full working example you can copy and paste:Understanding the vim() function
The vim() function returns a CodeMirror extension that adds Vim keybindings to your editor. It accepts an optional configuration object:
Options
status(boolean, optional): Whentrue, displays a status bar showing the current Vim mode (e.g., “—NORMAL—”, “—INSERT—”). Defaults tofalse.
Example with status bar
Important notes
If you’re not using
basicSetup, make sure you include the drawSelection plugin to correctly render the selection in visual mode.Extension ordering matters
The Vim extension must come before other keymaps in the extensions array:- Vim keybindings work correctly in normal mode
- Default keybindings (from
basicSetup) remain available in insert mode - Other custom keymaps can coexist with Vim bindings
Next steps
Now that you have a working Vim-enabled editor, explore advanced features:Customization
Learn how to customize keybindings and ex commands
Vim API
Access the Vim API to programmatically control the editor

