日本語

@vimee/plugin-textarea

Attach Vim keybindings to any HTML textarea

A lightweight plugin that attaches Vim keybindings to a standard HTML <textarea>. Ideal for simple use cases where syntax highlighting is not needed.

Installation

npm install @vimee/core @vimee/plugin-textarea

Usage

import { attach } from "@vimee/plugin-textarea";

const textarea = document.querySelector("textarea")!;

const vim = attach(textarea, {
  onChange: (value) => console.log("Content:", value),
  onModeChange: (mode) => console.log("Mode:", mode),
});

// Later: clean up
vim.destroy();

API

attach(textarea, options?)

OptionTypeDefaultDescription
readOnlybooleanfalseDisable editing
onChange(value: string) => voidContent change callback
onModeChange(mode: VimMode) => voidMode change callback
onYank(text: string) => voidYank callback
onSave(value: string) => voidSave callback
onAction(action: VimAction, key: string) => voidAction callback
indentStyle"space" | "tab""space"Indent character
indentWidthnumber2Indent width

Return: VimTextarea

MethodReturnDescription
.getMode()VimModeCurrent Vim mode
.getCursor()CursorPositionCursor position (0-based)
.getContent()stringBuffer content
.destroy()voidRemove Vim keybindings