https://github.com/val-town/codemirror-continue
Continue block comments in CodeMirror
https://github.com/val-town/codemirror-continue
codemirror codemirror6
Last synced: 2 months ago
JSON representation
Continue block comments in CodeMirror
- Host: GitHub
- URL: https://github.com/val-town/codemirror-continue
- Owner: val-town
- License: isc
- Created: 2023-12-15T21:25:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-14T16:01:31.000Z (5 months ago)
- Last Synced: 2025-04-14T14:14:51.462Z (2 months ago)
- Topics: codemirror, codemirror6
- Language: TypeScript
- Homepage: https://val-town.github.io/codemirror-continue/
- Size: 86.9 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @valtown/codemirror-continue
This **continues block comments when you
hit Enter** in [CodeMirror](https://codemirror.net/).Like when you're typing and you're here:
```ts
/**
```When you hit enter, you want it to do this:
```ts
/**
*
```Right? Well, this CodeMirror extension does just that. It
also handles the case where you're on the last line of a
comment, like```ts
/**
* My comment
*
```And you hit `/`, it'll _delete_ the previous space, giving you
```ts
/**
* My comment
*/
```Spectacular! Get it?
## Usage
Import `continueKeymap`:
```ts
import { continueKeymap } from "@valtown/codemirror-continue";
```Import `keymap` and `Prec`:
```ts
import { Prec } from "@codemirror/state";
import { keymap } from "@codemirror/view";
```Add the keybinding to your CodeMirror instance's `extensions` array:
```ts
extensions: [
basicSetup,
// … other setup
Prec.high(keymap.of(continueKeymap)),
],
```And that's it! This will only do anything if your CodeMirror
is using a language that supports `/* */` style block comments,
like JavaScript and TypeScript.