{"id":15020939,"url":"https://github.com/pollrobots/vim-monaco","last_synced_at":"2025-10-26T17:12:17.592Z","repository":{"id":246801867,"uuid":"823435602","full_name":"PollRobots/vim-monaco","owner":"PollRobots","description":"vim mode for use with monaco-editor","archived":false,"fork":false,"pushed_at":"2024-11-22T05:27:03.000Z","size":348,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-08T23:54:40.505Z","etag":null,"topics":["monaco","vim"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/PollRobots.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-07-03T03:18:46.000Z","updated_at":"2025-04-28T19:23:56.000Z","dependencies_parsed_at":"2024-07-08T09:20:33.707Z","dependency_job_id":"4caa8faa-eb8d-42d6-9a50-b09da8ba5c54","html_url":"https://github.com/PollRobots/vim-monaco","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"35da42840613150c8d44e42d28fe79ecd6a15199"},"previous_names":["pollrobots/vim-monaco"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/PollRobots/vim-monaco","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PollRobots%2Fvim-monaco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PollRobots%2Fvim-monaco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PollRobots%2Fvim-monaco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PollRobots%2Fvim-monaco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PollRobots","download_url":"https://codeload.github.com/PollRobots/vim-monaco/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PollRobots%2Fvim-monaco/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274070709,"owners_count":25217382,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["monaco","vim"],"created_at":"2024-09-24T19:55:54.857Z","updated_at":"2025-10-26T17:12:12.541Z","avatar_url":"https://github.com/PollRobots.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## vim-monaco\n\nvim mode for use with the [Monaco Editor](https://microsoft.github.io/monaco-editor/)\n\n[![npm version](https://badge.fury.io/js/vim-monaco.svg)](https://npmjs.com/package/vim-monaco)\n\n**Note:** This package does not include the [monaco-editor](https://npmjs.org/package/monaco-editor). It requires that Monaco has already been loaded, and depends on `window.monaco` having been populated. See the `monaco-editor` readme for how to accomplish this.\n\n## Sample\n\nYou can see this in use at [monaco-and-vim](https://pollrobots.com/monaco-and-vim), the code of which is at [github.com/pollrobots/monaco-and-vim](https://github.com/pollrobots/monaco-and-vim), and described in detail in this [blog article.](https://pollrobots.com/blog/typescript/vim/code/2024/07/03/monaco-and-vim.html)\n\n### Basic Usage\n\nAt a _minimum_ you can simply\n\n```typescript\nimport { VimMode } from 'vim-monaco';\n\n.\n.\n.\n\n// editor is a monaco.editor.IStandaloneCodeEditor\nconst vimMode = new VimMode(editor);\n// enable vim mode.\nvimMode.enable();\n```\n\n### Status Bar\n\nIt isn't particularly usable without a status bar, there is no mode indication, and no way to input commands.\n\nThe `VimMode` constructor has an optional second parameter `statusBar: IStatusBar`.\n\nThe `IStatusBar` type documentation describes how this needs to be implemented.\n\nAlternatively, there is a simple DOM implementation of this that can be created\nusing `makeDomStatusBar` which takes two arguments. A parent DOM node (to which the status bar will append itself), and a callback function that will be used to pass the focus back to Monaco\n\n```typescript\nimport { VimMode, makeDomStatusBar } from \"vim-monaco\";\n\n// parent is an html element (likely the parent of the editor)\n// editor is a monaco.editor.IStandaloneCodeEditor\nconst statusBar = makeDomStatusBar(parent, () =\u003e editor.focus());\nconst vimMode = new VimMode(editor, statusBar);\n// enable vim mode.\nvimMode.enable();\n```\n\n[jsfiddle example](https://jsfiddle.net/na4kLj0v/5/)\n\n### File load and save\n\nBy default `:write`, `:edit` and `:save` don't do anything. You can enable this functionality by adding event listeners to the `vimMode` object for the `open-file` and `save-file` events.\n\nThe vim mode doesn't track the current filename, so these commands will only send any filename information passed in to the command.\n\nGetting the current editor text for saving, and overwriting it for opening need to be handled directly with the IStandaloneCodeEditor instance.\n\n```typescript\nvimMode.addEventListener(\"open-file\", () =\u003e {\n  // code to open a file\n});\nvimMode.addEventListener(\"save-file\", (evt) =\u003e {\n  // the filename specified in a :save command (for example)\n  const filename = evt.filename;\n  const contents = editor.getValue();\n  // code to save the file\n});\n```\n\n### Clipboard\n\nThe `*` and `+` clipboard registers are not implemented by default. To enable interaction with the system clipboad you need to implement `IRegister` and add the two clipboard registers.\n\nBecause getting the contents of the clipboard is asynchronous, the vim mode raises a `clipboard` event whenever the keybuffer indicates that one of the clipboard registers is about to be accessed. This can be used to pre-fetch the cliboard contents.\n\n```typescript\nconst clipboard = new ClipboardRegister(); // a class that implements IRegister\nvimMode.setClipboardRegister(clipboard);\nvimMode.addEventListener(\"clipboard\", () =\u003e clipboard.update());\n```\n\n### Extras\n\n- `vimMode.disable()` will disable the vim mode. This reverts the editor to its default inferior key bindings.\n- `vimMode.executeCommand(cmd)` can be used to execute a command. For example `set iskeyword+=-` would add '-' to the set of keyword characters (used by `w` `*` etc.)\n- `vimMode.setOption` can be used to set options. One use of this is to set the theme. The vim instance can use the ':colorscheme' command to get and set the theme, but while it can set the theme on the monaco editor instance, it cannot read the current theme name, so calling this on external theme changes will keep the value in sync.\n\n## Acknowledgements\n\nThis was based on the [monaco-vim](https://github.com/brijeshb42/monaco-vim)\npackage by Brijesh Bittu.\n\nUnfortunately that package didn't work for my needs, it depends on internal\nfeatures of an older version of monaco. So I ported to typescript and made some\ndifferent design decisions to allow me to avoid those dependencies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollrobots%2Fvim-monaco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpollrobots%2Fvim-monaco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollrobots%2Fvim-monaco/lists"}