folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.22k stars 27 forks source link

feature: Is any way to use '/' but don't use '?' #284

Open Mr-LLLLL opened 7 months ago

Mr-LLLLL commented 7 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I want to use '/' to flash any where with flash.nvim, but keep '?' to search any word in old way. I test bind '/' to flash.jump(), but sometimes i want to '/' to search word like old way, i call flash.toggle() is not work. cause flash.toggle() control the search not flash.jump().

Describe the solution you'd like

I think diff the '/' and '?' in config, make flash search use '/' or '?' is good way?

Describe alternatives you've considered

nope

Additional context

No response

artfulrobot commented 4 months ago

If I understand right:

Then you can achieve that with config like

{
  "folke/flash.nvim",
  keys = {
    { "/", mode = { "n", "x", "v" }, function() require("flash").jump(); end, desc = "Flash Jump" },
    { "?", mode = { "n", "x", "v" }, function() require("flash").toggle(false); vim.api.nvim_feedkeys('?', 'n', true) end, desc = "Normal backward search" },
  }
}

If you wanted ? to do what nvim does normally on / (forward search) just change the feedkeys bit.

Mr-LLLLL commented 3 months ago

artfulrobot commented Feb 20, 2024

But i notice in your mapping, here always call require("flash").toggle(false), this will change the flash setting, is that OK?

artfulrobot commented 3 months ago

@Mr-LLLLL well it's fine by me because / will do the flash jump type search always anyway. Basically, I only want flash search for / and any other search should be normal search.

mycf commented 2 months ago

hope can help you / for old way

vim.keymap.set('n', '/', function() 
          require("flash").toggle(false)

        vim.fn.feedkeys("/", "n")
end)

vim.api.nvim_create_autocmd("CmdlineLeave", {
  pattern = "*",
  callback = function()
    require("flash").toggle(true)
  end,
})