I there a way to remap / that trigger builtin search function of vim to another search fuzzy function and how to achieve that?

  • You should be able to use fzf.vim to get a fuzzy search in your buffer content (at least that's what the commands Lines and BLines seems to do). But I don't think you can override / to get the same interface as the built-in search, at best you could remap / to start the fzf command. Note that you might also be interested by :h :grep depeding on what you actually want to do. – statox Nov 9 '18 at 10:45
  • @statox: I tried map / :<fuzzy>, doesn't work. Did I miss something? – Tuyen Pham Nov 9 '18 at 10:56
  • 1
    Vim does not contain a <fuzzy> function, you would have to implement a fuzzy search yourself – Christian Brabandt Nov 9 '18 at 10:57
  • 1
    @TuyenPham Yeah you probably missed something. I don't use but I don't think fzf provides a :<fuzzy> command. You should read the doc, install fzf, install fzf.vim, try to make a fuzzy search in the command line and once everything works you can try to create your mapping. – statox Nov 9 '18 at 10:58
  • Thanks guys, nnoremap / :FuzzySearch<CR> work as expected. :) – Tuyen Pham Nov 9 '18 at 11:11

I use plugin that expose FuzzySearch to call its function, we overwrite builtin search function of vim that triggered by press / by this remap: nnoremap / :FuzzySearch<CR>.

nnoremap: Only apply in normal mode, no remap allowed.

<CR>: Because this function need to be called before accept the next argument that is a search string, so we don't have to explicitly press enter.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.