- Notifications
You must be signed in to change notification settings - Fork18
Incremental fuzzy search motion plugin for Neovim
License
rlane/pounce.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Pounce is a motion plugin similar toEasyMotion,Sneak,Hop, andLightspeed. It's based on incremental fuzzy search. Here's a demo:
The demo shows searching for the word "ht_mask" by typing "s" to activatePounce, "htm" to refine the search, and then "J" to select the match.
Using vim-plug:
Plug 'rlane/pounce.nvim'The:Pounce command starts the motion. Type the character at the destinationand Pounce will highlight all matches on screen. Next, refine the matches bytyping more characters (in order) that are present after the destination. Thefirst letter of the match will be replaced with an uppercase "accept key". Youcan hit that key to jump to the match, or continue refining the search. Enteraccepts the best match (highlighted in blue). Escape cancels the motion andleaves the cursor at its previous position.
You can also use:Pounce <chars> to initialize the search with<chars>. Youcan directly hit the accept key to jump to that match or continue refining asnormal. You can use this with<C-r> to initialize the search with thecontents of a register, For example<C-r>/ will initialize the search withthe last search pattern you used in/. You can also consider using<expr>mappings or lua callbacks withvim.fn.expand. For these use cases thecommandsPounceReg <regname> andPounceExpand <expr> are defined.
The:PounceRepeat command works the same way but is initialized with theinput from the previous Pounce command.
No mappings are created by default. Here's a suggestion:
nmaps<cmd>Pounce<CR>nmapS<cmd>PounceRepeat<CR>xmaps<cmd>Pounce<CR>omapgs<cmd>Pounce<CR> " 's' is used by vim-surroundnmapS:Pounce<C-r>/<cr> " note: if you want to use<C-r> you cannot use<cmd>
You can also use the lua api directly:
localmap=vim.keymap.setmap("n","s",function()require'pounce'.pounce { }end)map("n","S",function()require'pounce'.pounce {do_repeat=true }end)map("x","s",function()require'pounce'.pounce { }end)map("o","gs",function()require'pounce'.pounce { }end)map("n","S",function()require'pounce'.pounce {input= {reg="/"} }end)
Thepounce function takes a table as its argument, you can use any keys thatsetup accepts, as well as:
require'pounce'.pounce{do_repeat=true|false-- to reuse the last pounce searchinput=string|table-- a string to initialize the input, or a table:input= {reg=string-- the name of a vim register to use as the input (:h registers)expand=string-- an expression passed to vim.fn.expand (:h expand()) }}
Configuration is done with thesetup function. It's optional to callsetup.Here are the defaults:
require'pounce'.setup{accept_keys="JFKDLSAHGNUVRBYTMICEOXWPQZ",accept_best_key="<enter>",multi_window=true,debug=false,}
Note thataccept_keys allows you to configure the order in which accept keysdisplay – closest proximity match gets the first letter in theaccept_keysstring. Users of alternative keyboard layouts may wish to amend that string.Colemak DHm might start withNTESIROA... for example.
Below are listed some example extra commands you can use:
<cmd>PounceReg /<cr>" Pounce with last search pattern<cmd>PounceReg0<cr>" Pounce with last yank<cmd>PounceReg\"<cr>" Pounce with last d/c/y<cmd>PounceReg .<cr>" Pounce with last inserted text\"zy<cmd>PounceRegz<cr>" From visual mode: Pounce using the selection as the input<cmd>PounceExpand<cword><cr>" Pounce with the current word<cmd>PounceExpand%<cr>" Pounce with the current filename
There are quite a few plugins in this space. Here are some alternatives toPounce:
About
Incremental fuzzy search motion plugin for Neovim
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.
