How to use monaco-vim - 10 common examples

To help you get started, we’ve selected a few monaco-vim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-rpc / playground / src / hooks / useMonacoVimMode.tsx View on Github external
run: () => {
        if (vimMode) {
          vimMode.dispose();
        }
        setVimMode(initVimMode(editor));
      },
    });
github open-rpc / playground / src / MonacoJSONEditor.tsx View on Github external
public onVimKeybind() {
    if (this.vimMode) {
      this.vimMode.dispose();
      if (this.statusNode) {
        this.statusNode.innerHTML = "";
      }
      this.vimMode = null;
      return;
    }
    this.statusNode = document.getElementById("vim-status-bar");
    this.vimMode = initVimMode(this.editorInstance, this.statusNode);
    return;
  }
  public render() {
github expo / snack-web / snack / components / Editor / MonacoEditor.js View on Github external
_toggleMode = mode => {
    if (mode === 'vim') {
      this._vim = initVimMode(this._editor, this._statusbar);
    } else {
      this._vim && this._vim.dispose();
    }
  };
github exercism / website / app / javascript / components / student / editor / ExercismMonacoEditor.tsx View on Github external
useEffect(() => {
    if (!editorRef.current || !statusBarRef.current) {
      return
    }

    keybindingRef.current?.dispose()

    switch (keybindings) {
      case Keybindings.VIM:
        keybindingRef.current = initVimMode(
          editorRef.current,
          statusBarRef.current
        )

        break
      case Keybindings.EMACS:
        const extension = new EmacsExtension(editorRef.current)
        extension.start()

        keybindingRef.current = extension

        break
    }
  }, [editorRef, statusBarRef, keybindings, keybindingRef])
github open-rpc / playground / src / MonacoJSONEditor.js View on Github external
onVimKeybind(e) {
    if (this.vimMode) {
      this.vimMode.dispose();
      this.statusNode.innerHTML = '';
      this.vimMode = null;
      return;
    }
    this.statusNode = document.getElementById('vim-status-bar');
    this.vimMode = initVimMode(this.editorInstance, this.statusNode);
    return;
  }
  render() {
github mattgodbolt / compiler-explorer / static / panes / editor.js View on Github external
Editor.prototype.enableVim = function () {
    this.vimMode = monacoVim.initVimMode(this.editor, this.domRoot.find('#v-status')[0]);
    this.vimFlag.prop("class", "btn btn-info");
    this.editor.vimInUse = true;
};
github expo / snack-web / src / client / components / Editor / MonacoEditor.tsx View on Github external
_toggleMode = (mode: EditorMode) => {
    if (mode === 'vim' && this._editor) {
      this._vim = initVimMode(this._editor, this._statusbar.current as HTMLDivElement);
    } else {
      this._vim && this._vim.dispose();
    }
  };
github cloudcmd / deepword / client / api / vim.js View on Github external
export const enableVim = (editor, el) => {
    const statusEl = el.querySelector('#deepword-vim');
    statusEl.innerHTML = '';
    
    vimMode = initVimMode(editor, statusEl);
};
github mattgodbolt / compiler-explorer / static / panes / editor.js View on Github external
Editor.prototype.onInsertKey = function (event) {
    if (this.editor.vimInUse) {
        var currentState = monacoVim.VimMode.Vim.maybeInitVimState_(this.vimMode);
        if (!currentState.insertMode) {
            var insertEvent = {};
            insertEvent.preventDefault = event.preventDefault;
            insertEvent.stopPropagation = event.stopPropagation;
            insertEvent.browserEvent = {};
            insertEvent.browserEvent.key = 'i';
            insertEvent.browserEvent.defaultPrevented = false;
            insertEvent.keyCode = 39;
            this.vimMode.handleKeyDown(insertEvent);
        }
    }
};
github mattgodbolt / compiler-explorer / static / panes / editor.js View on Github external
Editor.prototype.onEscapeKey = function () {
    if (this.editor.vimInUse) {
        var currentState = monacoVim.VimMode.Vim.maybeInitVimState_(this.vimMode);
        if (currentState.insertMode) {
            monacoVim.VimMode.Vim.exitInsertMode(this.vimMode);
        } else if (currentState.visualMode) {
            monacoVim.VimMode.Vim.exitVisualMode(this.vimMode, false);
        }
    }
};

monaco-vim

Vim keybindings for monaco-editor

MIT
Latest version published 12 months ago

Package Health Score

64 / 100
Full package analysis

Popular monaco-vim functions