You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@codemirror/lang-cpp

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-cpp

C++ language support for the CodeMirror code editor

6.0.3
latest
Source
npmnpm
Version published
Weekly downloads
294K
-15.45%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/lang-cpp?

@codemirror/lang-cpp is a language support package for CodeMirror 6 that provides syntax highlighting, code folding, and other editing features for C++ code.

What are @codemirror/lang-cpp's main functionalities?

Syntax Highlighting

This code sets up a CodeMirror editor with C++ syntax highlighting. The `cpp` function from `@codemirror/lang-cpp` is used to enable C++ language support.

import { cpp } from '@codemirror/lang-cpp';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() { return 0; }',
  extensions: [basicSetup, cpp()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Code Folding

This code sets up a CodeMirror editor with C++ syntax highlighting and code folding capabilities. The `foldGutter` and `foldKeymap` extensions are used to enable code folding.

import { cpp } from '@codemirror/lang-cpp';
import { foldGutter, foldKeymap } from '@codemirror/fold';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() {\n  // code\n  return 0;\n}',
  extensions: [basicSetup, cpp(), foldGutter(), foldKeymap]
});

const view = new EditorView({
  state,
  parent: document.body
});

Autocomplete

This code sets up a CodeMirror editor with C++ syntax highlighting and autocomplete functionality. The `autocompletion` extension is used to provide autocomplete suggestions.

import { cpp } from '@codemirror/lang-cpp';
import { autocompletion } from '@codemirror/autocomplete';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() {\n  // code\n  return 0;\n}',
  extensions: [basicSetup, cpp(), autocompletion()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Other packages similar to @codemirror/lang-cpp

Keywords

editor

FAQs

Package last updated on 19 Jun 2025

Did you know?

Socket

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.

Install

Related posts