1.0.4 • Published 8 months ago

@rigstech/codemirror-vscodesearch v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

VSCode Style Search & Replace for CodeMirror

A VSCode-styled Search and Replace extension for CodeMirror 6, built on top of the core @codemirror/search package. This plugin provides a familiar find/replace experience inspired by Visual Studio Code, complete with custom keybindings and inline input styling.

✨ Features

  • Find and Replace support with UI controls
  • Toggle options: Regex, Case Sensitivity, Whole Word
  • Inline match highlighting
  • Keyboard shortcuts modeled after VSCode
  • Fully integrated with CodeMirror's state and view systems

🚀 Installation

Make sure you have @codemirror/view, @codemirror/state, and @codemirror/search installed:

npm install @rigstech/codemirror-vscodeSearch

Then include the plugin in your CodeMirror setup.

🛠️ Usage

Import

import { vscodeSearch, customSearchKeymap } from '@rigstech/codemirror-vscodeSearch';
import { keymap } from '@codemirror/view';

Add to Editor Extensions

const editor = new EditorView({
  state: EditorState.create({
    doc: 'Your initial content here...',
    extensions: [
      vscodeSearch,
      keymap.of([
        // Your other keymaps...
        ...customSearchKeymap
      ])
    ]
  }),
  parent: document.getElementById('editor')!
});

🎹 Default Keybindings

ShortcutAction
Mod+FShow Search UI
Mod+HShow Replace UI
EscapeHide Search UI
EnterFind/Replace Next
Shift+EnterFind Previous
Mod+Alt+EnterReplace All
Alt+CToggle Case Sensitivity
Alt+WToggle Whole Word
Alt+RToggle Regex
Mod+ASelect All (search/replace box)

Mod is Cmd on macOS and Ctrl on Windows/Linux.

📦 Project Structure

This plugin is structured into:

commands:               Codemirror commands for hotkeys
keymap:                 Keymap defition
plugin:                 Main ViewPlugin
state:                  Extension States
theme:                  Styling
utility:                Helper Functions
FindReplaceControl:     Extension Logic

📄 License

MIT — feel free to use and modify for your own projects!