How to clear vim search highlight

Bug report

After running the :substitute command on a note I still have yellow boxes around my matches. I tried using esc and :set invhlsearch but no :game_die:. Which is basically my way of saying I’m deeply ashamed to have to ask! In my defense, I checked the forum search and the plugin GH page first.

Any ideas?
→

Environment

  • Platform: MacOS
  • Platform version: 12.4 Mont
  • App Version: 5.5.0 (5.5.0)

How to reproduce

  1. use :s/xxx/yyy
  2. yellow boxes appear on all notes with the search term
  3. ESC does not remove them

Hi Jose,

Thanks for the question.
You can use :nohlsearch ex command to clear the search highlights.

Hi Takuya,

How can bind an escape key to map with ex: noh to keymap.json file?

Thank you,
Bundit

You can define a custom command that invokes the nohl ex command like this in your init.js:

const Vim = require('codemirror').Vim

inkdrop.commands.add(
  document.body,
  'custom:nohl',
  (event) => {
    const cm = inkdrop.getActiveEditor().cm
    vim.exCommandDispatcher.processCommand(cm, 'nohl')
  }
)

then, bind this command to any key combination.
If you’d like to bind it to esc in the editor (selector: '.CodeMirror textarea'), you have to invoke editor:single-selection at the end of your command.