npm

@valtown/codemirror-continue
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@valtown/codemirror-continue

This continues block comments when you hit Enter in CodeMirror.

Like when you're typing and you're here:

/**<cursor>

When you hit enter, you want it to do this:

/**
 * <cursor>

Right? Well, this CodeMirror extension does just that. It also handles the case where you're on the last line of a comment, like

/**
 * My comment
 * <cursor>

And you hit /, it'll delete the previous space, giving you

/**
 * My comment
 */

Spectacular! Get it?

Usage

Import continueKeymap:

import { continueKeymap } from "@valtown/codemirror-continue";

Import keymap and Prec:

import { Prec } from "@codemirror/state";
import { keymap } from "@codemirror/view";

Add the keybinding to your CodeMirror instance's extensions array:

extensions: [
  basicSetup,
  // … other setup
  Prec.high(keymap.of(continueKeymap)),
],

And that's it! This will only do anything if your CodeMirror is using the JavaScript or TypeScript mode.

Readme

Keywords

Package Sidebar

Install

npm i @valtown/codemirror-continue

Weekly Downloads

522

Version

2.0.0

License

ISC

Unpacked Size

21.5 kB

Total Files

12

Last publish

Collaborators

  • tmcw
  • stevekrouse