A terminal-based Markdown and code editor with WYSIWYG rendering and LSP support.
mq-edit is a Rust-based TUI (Text User Interface) editor that provides:
- Markdown WYSIWYG: The line under the cursor displays source, other lines show rich formatted text
- LSP Integration: Full Language Server Protocol support for code intelligence
- Multi-language support: Rust, Python, MQ (Markdown Query Language), and more
Built on top of the mq-markdown parser with full LSP capabilities.
curl -fsSL https://raw.githubusercontent.com/harehare/mq-edit/main/bin/install.sh | bashThe installer will:
- Download the latest release for your platform
- Verify the binary with SHA256 checksum
- Install to
~/.mq-edit/bin/ - Update your shell profile (bash, zsh, or fish)
After installation, restart your terminal or run:
source ~/.bashrc # or ~/.zshrc, or ~/.config/fish/config.fish# Install from crates.io
cargo install mq-edit
# Install using binstall
cargo binstall mq-edit@0.1.0git clone https://github.com/harehare/mq-edit.git
cd mq-edit
cargo build --release
# Binary will be at target/release/mq-edit# Open a Markdown file
mq-edit README.md
# Open a Rust file (with LSP support)
mq-edit src/main.rs
# Open an MQ file (Markdown Query Language)
mq-edit query.mq
# Create a new file (empty buffer)
mq-edit
# Initialize default configuration file
mq-edit --init-config
# Show help
mq-edit --help| Key | Action |
|---|---|
Ctrl+S |
Save file (opens save dialog for new files) |
Ctrl+Q / Esc |
Quit |
Alt+B / F2 |
Toggle file browser |
Ctrl+Space |
Code completion (LSP) |
Ctrl+D |
Go to definition (LSP) |
Ctrl+B |
Navigate back |
Ctrl+F |
Navigate forward |
Ctrl+G |
Go to line |
Ctrl+E |
Execute mq query |
F3 |
Search |
F4 |
Find and replace |
Up/Down |
Move cursor / Select completion |
Enter |
Apply completion |
mq-edit supports pipe mode, allowing you to read from stdin and write to stdout. This is useful for combining with mq and other command-line tools. In pipe mode, pressing Esc exits immediately without a save confirmation dialog — the edited content is written to stdout on exit.
# Edit mq output interactively, then pass the result to the next command
cat README.md | mq '.h' | mq-edit | mq 'downcase()'
# Extract links, edit them, and save to a file
cat README.md | mq '.link' | mq-edit > links.md
# Transform markdown with mq, review and edit interactively, then write back
mq '.[] | select(.h.depth > 1)' README.md | mq-edit > headings.md
# Edit text from clipboard (macOS)
pbpaste | mq-edit | pbcopymq-edit uses a TOML configuration file for customizing keybindings and LSP servers.
- Linux:
~/.config/mq/edit/config.toml - macOS:
~/Library/Application Support/mq/edit/config.toml - Windows:
%APPDATA%\mq/edit\config.toml
Run mq-edit --init-config to create a default configuration file with all available keybindings.
Configure language servers for different file types:
# Rust Language Server
[lsp.servers.rust]
command = "rust-analyzer"
args = []
enable_completion = true
enable_diagnostics = true
enable_goto_definition = true
# MQ Language Server (for .mq files)
[lsp.servers.mq]
command = "mq-lsp"
args = []
enable_completion = true
enable_diagnostics = true
enable_goto_definition = true
# Python Language Server
[lsp.servers.python]
command = "pyright-langserver"
args = ["--stdio"]
enable_completion = true
enable_diagnostics = true
enable_goto_definition = trueEdit the config file to change keybindings. Example:
[keybindings.quit]
code = "q"
modifiers = ["ctrl"] # Ctrl+Q to quit
[keybindings.quit_alt]
code = "esc"
modifiers = [] # Esc to quit (alternative)
[keybindings.save]
code = "s"
modifiers = ["ctrl"] # Ctrl+S to saveChoose from built-in syntax highlighting themes:
[editor]
# Syntax highlighting theme
theme = "base16-ocean.dark" # Default dark theme
# Other available themes:
# theme = "base16-ocean.light" # Light ocean theme
# theme = "base16-mocha.dark" # Mocha dark theme
# theme = "base16-eighties.dark" # Eighties dark theme
# theme = "InspiredGitHub" # GitHub-inspired light theme
# theme = "Solarized (dark)" # Solarized dark
# theme = "Solarized (light)" # Solarized lightAll themes are provided by the syntect library.
Note: Default keybindings have been changed to avoid conflicts with VSCode, Zellij, and other editors. All keybindings are customizable via the config file.
Arrow keys- Move cursorHome- Start of lineEnd- End of linePage Up/Down- Scroll page
Character keys- Insert textEnter- Insert newlineBackspace- Delete characterTab- Insert tab
Ctrl+S- Save file (opens save-as dialog for new files)Ctrl+QorEsc- Quit applicationAlt+B- Toggle file browser (changed fromCtrl+Bto avoid VSCode conflict)F2- Toggle file browser (alternative)
Ctrl+D- Go to definition (changed fromCtrl+Gto avoid conflict with goto line)Ctrl+B- Navigate back in jump historyCtrl+F- Navigate forward in jump historyCtrl+Space- Trigger code completionCtrl+L- Toggle line numbersCtrl+Shift+L- Toggle current line highlight
mq-edit has built-in support for mq (Markdown Query Language). Press Ctrl+E to open the query dialog and run mq queries against the current document.
Ctrl+E- Open mq query dialog- Type a query (e.g.
.heading,.link,.[] | upcase()) Enter- Execute query and insert result at cursor positionEsc- Close dialog
The query result is inserted at the current cursor position, and the cursor remains at the insertion start so you can review the output.
F3- Open search dialogF4- Open find and replace dialogCtrl+G- Go to line (opens line number dialog)
Up/Down- Navigate files and directoriesRight- Expand directoryLeft- Collapse directoryEnter- Open file or toggle directoryEsc- Close file browser
Same license as the mq project (MIT).
