Skip to content

feat: Add <leader> key support#282

Open
joaosa wants to merge 1 commit intoesm7:masterfrom
joaosa:feat/leader-key
Open

feat: Add <leader> key support#282
joaosa wants to merge 1 commit intoesm7:masterfrom
joaosa:feat/leader-key

Conversation

@joaosa
Copy link

@joaosa joaosa commented Feb 16, 2026

Adds <leader> support via text substitution in loadVimCommands(). No CodeMirror changes needed.

let mapleader = ","
nmap <leader>f :nohl<CR>

How it works: let mapleader directives are consumed by the plugin. <leader> tokens in mapping commands are replaced with the leader value before handleEx().

  • Default leader: \ (matches Vim)
  • Case-insensitive (<leader>, <Leader>, <LEADER>)
  • Single-pass: each let mapleader affects subsequent mappings only
  • Only substitutes in mapping commands (no false positives in exmap/jscommand/etc.)
  • Fully backwards-compatible
  • source command inherits leader

Closes #117

Parse `let mapleader` directives and substitute `<leader>` in mapping
commands before passing lines to CodeMirror's handleEx(). This is
pure text substitution at the plugin level — no CodeMirror changes needed.

- Default leader is `\` (backslash), matching Vim
- Case-insensitive: <leader>, <Leader>, <LEADER> all work
- Single-pass processing: each `let mapleader` affects subsequent mappings only
- Only substitutes in recognized mapping commands (no false positives)
- Backwards compatible: no change for users who don't use <leader>
- Works with `source` command (sourced files inherit/override leader)

Closes esm7#117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Leader key

1 participant