{"id":18109650,"url":"https://github.com/replit/codemirror-vim","last_synced_at":"2025-04-11T18:28:29.643Z","repository":{"id":36990805,"uuid":"410077928","full_name":"replit/codemirror-vim","owner":"replit","description":"Vim keybindings for CM6","archived":false,"fork":false,"pushed_at":"2024-09-16T20:40:37.000Z","size":604,"stargazers_count":287,"open_issues_count":30,"forks_count":29,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-09-17T02:09:40.971Z","etag":null,"topics":["codemirror","codemirror-6","editor","vim"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@replit/codemirror-vim","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-24T19:20:01.000Z","updated_at":"2024-09-16T05:41:45.000Z","dependencies_parsed_at":"2023-01-17T11:46:13.600Z","dependency_job_id":"eab0ac0e-90cb-4df3-bd4c-54d99fa6ed88","html_url":"https://github.com/replit/codemirror-vim","commit_stats":{"total_commits":120,"total_committers":13,"mean_commits":9.23076923076923,"dds":0.5166666666666666,"last_synced_commit":"7e70ff7d321f9aa6600616a4d2ee81327394533a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replit","download_url":"https://codeload.github.com/replit/codemirror-vim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248457429,"owners_count":21106901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codemirror","codemirror-6","editor","vim"],"created_at":"2024-11-01T00:01:53.380Z","updated_at":"2025-04-11T18:28:29.613Z","avatar_url":"https://github.com/replit.png","language":"JavaScript","readme":"# Vim keybindings for CM6\n\n\u003cspan\u003e\u003ca href=\"https://replit.com/@util/codemirror-vim\" title=\"Run on Replit badge\"\u003e\u003cimg src=\"https://replit.com/badge/github/replit/codemirror-vim\" alt=\"Run on Replit badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan\u003e\u003ca href=\"https://www.npmjs.com/package/@replit/codemirror-vim\" title=\"NPM version badge\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@replit/codemirror-vim?color=blue\" alt=\"NPM version badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n## Installation\n\n```sh\nnpm i @replit/codemirror-vim\n```\n\n## Usage\n\n```js\nimport { basicSetup, EditorView } from 'codemirror';\nimport { vim } from \"@replit/codemirror-vim\"\n\nlet view = new EditorView({\n  doc: \"\",\n  extensions: [\n    // make sure vim is included before other keymaps\n    vim(), \n    // include the default keymap and all other keymaps you want to use in insert mode\n    basicSetup, \n  ],\n  parent: document.querySelector('#editor'),\n})\n```\n\u003e **Note**:\n\u003e if you are not using `basicSetup`, make sure you include the [drawSelection](https://codemirror.net/docs/ref/#view.drawSelection) plugin to correctly render the selection in visual mode.\n\n## Usage of cm5 vim extension api\n\nThe 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\n\n```js\nimport {Vim, getCM} from \"@replit/codemirror-vim\"\n\nlet cm = getCM(view)\n// use cm to access the old cm5 api\nVim.exitInsertMode(cm)\nVim.handleKey(cm, \"\u003cEsc\u003e\")\n```\n\n### Define additional ex commands\n```js\nVim.defineEx('write', 'w', function() {\n    // save the file\n});\n```\n\n### Map keys\n```js\nVim.map(\"jj\", \"\u003cEsc\u003e\", \"insert\"); // in insert mode\nVim.map(\"Y\", \"y$\"); // in normal mode\n```\n\n### Unmap keys\n\n```js\nVim.unmap(\"jj\", \"insert\");\n```\n\n### Add custom key\n\n```js\n  defaultKeymap.push({ keys: 'gq', type: 'operator', operator: 'hardWrap' });\n  Vim.defineOperator(\"hardWrap\", function(cm, operatorArgs, ranges, oldAnchor, newHead) {\n    // make changes and return new cursor position\n  });\n```\n\n## Credits\n\nThis plugin was originally authored by [@mightyguava](https://github.com/mightyguava) (Yunchi Luo) as part of [CodeMirror](https://github.com/codemirror/dev), before being extracted and maintained here.\n","funding_links":[],"categories":["Keybindings"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fcodemirror-vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplit%2Fcodemirror-vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fcodemirror-vim/lists"}