Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@codemirror/commands
Advanced tools
Collection of editing commands for the CodeMirror code editor
@codemirror/commands is a package that provides a collection of commands for the CodeMirror code editor. These commands are used to manipulate the editor's content, navigate through the text, and perform various editing operations. The package is designed to be used with the CodeMirror 6 framework.
Basic Editing Commands
This feature includes basic editing commands such as inserting a newline and deleting a character forward. The code sample demonstrates how to bind these commands to specific keys in a CodeMirror editor instance.
import { insertNewline, deleteCharForward } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'Enter', run: insertNewline
}, {
key: 'Delete', run: deleteCharForward
}])
]
}),
parent: document.body
});
Selection Commands
This feature includes commands for selecting text, such as selecting all text or selecting the current line. The code sample shows how to bind these commands to specific key combinations in a CodeMirror editor instance.
import { selectAll, selectLine } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'Ctrl-a', run: selectAll
}, {
key: 'Ctrl-l', run: selectLine
}])
]
}),
parent: document.body
});
Navigation Commands
This feature includes navigation commands such as moving the cursor left or right by one character. The code sample demonstrates how to bind these commands to the arrow keys in a CodeMirror editor instance.
import { cursorCharLeft, cursorCharRight } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'ArrowLeft', run: cursorCharLeft
}, {
key: 'ArrowRight', run: cursorCharRight
}])
]
}),
parent: document.body
});
Monaco Editor is the code editor that powers Visual Studio Code. It provides a rich set of commands for editing, navigating, and managing code. Compared to @codemirror/commands, Monaco Editor offers a more comprehensive and integrated development experience, especially for larger projects.
Ace is a standalone code editor written in JavaScript. It provides a wide range of commands for code editing and navigation. While @codemirror/commands is designed to work with the CodeMirror 6 framework, Ace is a self-contained editor with its own set of features and commands.
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It provides a variety of commands for text editing and navigation. The original CodeMirror (version 5) has a different API and architecture compared to CodeMirror 6 and its @codemirror/commands package.
[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]
This package implements a collection of editing commands for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
import {EditorView, keymap} from "@codemirror/view"
import {standardKeymap, selectLine} from "@codemirror/commands"
const view = new EditorView({
parent: document.body,
extensions: [
keymap.of([
...standardKeymap,
{key: "Alt-l", mac: "Ctrl-l", run: selectLine}
])
]
})
6.8.0 (2025-01-08)
The new cursorGroupForwardWin
and selectGroupForwardWin
commands implement Windows-style forward motion by group.
FAQs
Collection of editing commands for the CodeMirror code editor
The npm package @codemirror/commands receives a total of 1,253,633 weekly downloads. As such, @codemirror/commands popularity was classified as popular.
We found that @codemirror/commands demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.