
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@replit/codemirror-vim
Advanced tools
npm i @replit/codemirror-vim
import { basicSetup, EditorView } from 'codemirror';
import { vim } from "@replit/codemirror-vim"
let view = new EditorView({
doc: "",
extensions: [
// make sure vim is included before other keymaps
vim(),
// include the default keymap and all other keymaps you want to use in insert mode
basicSetup,
],
parent: document.querySelector('#editor'),
})
Note: if you are not using
basicSetup
, make sure you include the drawSelection plugin to correctly render the selection in visual mode.
The same api that could be used in previous version of codemirror https://codemirror.net/doc/manual.html#vimapi, can be used with this plugin too, just replace the old editor instance with view.cm
in your code
import {Vim, getCM} from "@replit/codemirror-vim"
let cm = getCM(view)
// use cm to access the old cm5 api
Vim.exitInsertMode(cm)
Vim.handleKey(cm, "<Esc>")
Vim.defineEx('write', 'w', function() {
// save the file
});
Vim.map("jj", "<Esc>", "insert"); // in insert mode
Vim.map("Y", "y$"); // in normal mode
Vim.unmap("jj", "insert");
defaultKeymap.push({ keys: 'gq', type: 'operator', operator: 'hardWrap' });
Vim.defineOperator("hardWrap", function(cm, operatorArgs, ranges, oldAnchor, newHead) {
// make changes and return new cursor position
});
This plugin was originally authored by @mightyguava (Yunchi Luo) as part of CodeMirror, before being extracted and maintained here.
FAQs
Vim keybindings for CodeMirror 6
The npm package @replit/codemirror-vim receives a total of 28,163 weekly downloads. As such, @replit/codemirror-vim popularity was classified as popular.
We found that @replit/codemirror-vim demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 22 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.