/ followed by a command name.
Overview
Type/ at the start of a line or after a space to bring up a menu of markdown elements you can insert:
- Headings (H1, H2, H3)
- Lists (bullet, numbered, todo)
- Code blocks
- Blockquotes
- Horizontal rules
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:1-17
Available Commands
| Command | Syntax | Description |
|---|---|---|
| h1 | /h1 | # Large heading |
| h2 | /h2 | ## Medium heading |
| h3 | /h3 | ### Small heading |
| bullet-list | /bullet or /list | - Bullet list |
| numbered-list | /numbered or /1 | 1. Numbered list |
| quote | /quote | > Blockquote |
| code-block | /code | ``` Code block |
| todo | /todo | - [ ] Todo item |
| divider | /divider or /hr | --- Horizontal rule |
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:40-121
Usage
Basic Usage
- Type
/at the start of a new line - A suggestion menu appears
- Type to filter (e.g.,
/hshows headings) - Press
Enteror click to insert - The line is replaced with the markdown element
Examples
Insert Heading
Type:/h1
Result: # (cursor positioned after space)
Insert Code Block
Type:/code
Result:
Insert Todo
Type:/todo
Result: - [ ] (cursor positioned after space)
Insert Divider
Type:/divider
Result: --- (cursor at end)
Implementation
EditorSuggest System
Slash Commands uses Inkdown’sEditorSuggest API:
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:30-209
Command Structure
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:19-25
Insert Actions
Simple Prefix Insertion
For elements that just add a prefix:- Headings (
#,##, etc.) - Lists (
-,1.) - Blockquotes (
>) - Todos (
- [ ])
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:124-130
Complex Insertion
For elements with more structure:packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:85-100
Suggestion Menu UI
Rendering
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:178-201
Appearance
Settings
Enable/Disable Slash Commands
You can toggle slash commands in the plugin settings:- Open Settings → Plugins → Slash Commands
- Toggle “Enable slash commands”
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:11-17
Settings Tab
The plugin provides a settings tab:packages/plugins/src/slash-commands/SlashCommandsSettingTab.ts
Keyboard Navigation
Menu Navigation
↑/↓: Navigate suggestionsEnter: Select current suggestionEsc: Cancel and close menuTab: Navigate to next suggestion
Trigger Behavior
The menu triggers when:- You type
/at the start of a line - You type
/after a space - You continue typing after
/(filters suggestions)
- You select a suggestion
- You press
Esc - You move the cursor away
- You delete the
/
Extending Slash Commands
You can add custom slash commands in your plugins:Installation
The Slash Commands plugin is built-in and enabled by default. To toggle it:- Open Settings → Plugins
- Find “Slash Commands”
- Toggle the enable switch
Troubleshooting
Slash menu doesn’t appear
Solutions:- Check the plugin is enabled
- Check the “Enable slash commands” setting
- Ensure you’re typing
/at the start of a line or after a space - Try restarting Inkdown
Wrong command inserted
Cause: Selected wrong item from menu. Solution: Use arrow keys to navigate before pressing Enter.Menu appears in wrong places
Issue: Menu triggers when typing URLs or other slashes. Current behavior: Only triggers at line start or after space. URLs in the middle of text won’t trigger it.Command not working
Symptoms: Command inserts but cursor is in wrong place or format is wrong. Solution: This is likely a bug. Report it with:- Command used
- Expected behavior
- Actual behavior
- Example markdown before and after
API Reference
Plugin Class
packages/plugins/src/slash-commands/SlashCommandsPlugin.ts:212-259
SlashCommand Interface
EditorSuggest Methods
Performance
Suggestion Filtering
Filtering is very fast:- Simple string matching
- Case-insensitive
- Matches both ID and name
- O(n) where n is number of commands (~9 commands)
Menu Rendering
Menu renders only visible suggestions:- Virtualized list for large command sets
- Minimal DOM updates
- Smooth scrolling
See Also
Quick Finder
Fast file search and creation
Live Preview
Real-time markdown rendering
Editor API
Editor and suggestion system
Plugin Development
Create custom plugins
