CodeMirror Vim includes a status bar feature that displays the current Vim mode and other status information. This helps users understand which mode they’re in and provides visual feedback during command execution.
From the source code (index.ts:147-168), the status is updated based on Vim state:
updateStatus() { let dom = this.cm.state.statusbar; let vim = this.cm.state.vim; if (!dom || !vim) return; let dialog = this.cm.state.dialog; if (dialog) { if (dialog.parentElement != dom) { dom.textContent = ""; dom.appendChild(dialog); } } else { dom.textContent = "" var status = (vim.mode || "normal").toUpperCase(); if (vim.insertModeReturn) status += "(C-O)" this.statusButton.textContent = `--${status}--`; dom.appendChild(this.statusButton); dom.appendChild(this.spacer); } this.dom.textContent = vim.status; dom.appendChild(this.dom);}
The status panel is created when the status option is enabled (index.ts:428-435):
function statusPanel(view: EditorView): Panel { let dom = document.createElement("div"); dom.className = "cm-vim-panel"; let cm = (view as EditorViewExtended).cm; cm.state.statusbar = dom; cm.state.vimPlugin.updateStatus(); return { dom };}
You can access the current Vim status through the state:
import { getCM } from "@replit/codemirror-vim";const cm = getCM(view);// Get current modeconst mode = cm.state.vim?.mode || 'normal';console.log('Current mode:', mode);// Get current status messageconst status = cm.state.vim?.status || '';console.log('Status:', status);// Check if in insert modeconst isInsert = cm.state.vim?.insertMode;// Check if in visual modeconst isVisual = cm.state.vim?.visualMode;