Examples¶
Code examples showing how to use Kodemirror. Each example includes complete Kotlin snippets adapted from the upstream CodeMirror examples.
Getting started¶
- Basic Setup — Minimal editor with common extensions
- Gradle Setup — Adding Kodemirror to your project
Configuration¶
- Dynamic Configuration — Runtime reconfiguration with compartments
- Themes and Styling — Custom themes and syntax highlighting
- Tab Handling — Tab key behavior
- Read-Only Mode — Making the editor non-editable
Working with content¶
- Programmatic Changes — Inserting, replacing, and deleting text
- Selection Handling — Cursors, ranges, and multi-select
- Decorations — Marks, widgets, and line styling
Features¶
- Autocompletion — Code completion dropdown
- Linting — Diagnostics and error reporting
- Gutters — Line numbers and custom gutter markers
- Panels — UI strips above or below the editor
- Tooltips — Floating UI anchored to document positions
Advanced¶
- Zebra Stripes — Line-level decoration with ViewPlugin
- Language Package — Defining a language for Kodemirror
- Mixed-Language Parsing — Nested languages in one document
- Collaborative Editing — Real-time multi-user editing
- Split View — Two panes sharing one document
- Large Documents — Handling millions of lines efficiently
- Bidirectional Text — Right-to-left and mixed-direction text
- Inverted Effects — Undo/redo with state effects
- Internationalization — Translating UI strings
Complete sample¶
- Sample Editor — A full working Compose Desktop application with language switching, theme selection, and Material Design integration
See also the API Reference for generated KDoc documentation of every module.