4 ms·
Those are very creative use cases for fzf, I had never considered doing something like that. My usage of it probably counts as quite basic. That said, I use it
by tdfirth 6y ago
Those are very creative use cases for fzf, I had never considered doing something like that.
My usage of it probably counts as quite basic. That said, I use it constantly. I just love the feeling of real time interaction it gives - it is well and truly part of my muscle memory now.
I use the vim plugin too, which is also brilliant and makes navigating larger projects very quick and easy. I use these two extra bindings all the time:
nnoremap <silent> <C-Space> yiw:Rg <C-r>"<CR>
vnoremap <silent> <C-Space> y:Rg <C-r>"<CR>
They're very simple, but when combined with the ability to add search items to the quickfix list it makes for a pretty powerful workflow.
The first one in particular gives a great approximation of symbol search that 'just works' anywhere.
- lelandbatey 6y agoYeah, the ability to fake a "show all references to this identifier" via integrated ':Rg' is the greatest feature of FZF I've encountered yet, and makes for a passable substitute of one language-server must-haves.
- mssundaram 6y agoI must have bindings that are overriding what that should do, can you explain what <C-space> y and yiw should normally do?
- climb_stealth 6y ago'yiw' is yank inner word. It basically copies the current word from wherever you are in that word. The pure yank 'y' I presume would just work if you already have something highlighted. It looks like these shortcuts take the current word or current selection and pass it to Rg [0] to be searched for. I don't have the plugin but it sounds super useful and I'm going to give them a try. [0] Rg being ripgrep, see https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep
- mssundaram 6y agoThank you!
- tdfirth 6y agoHey, sorry that I didn't really try to explain the bindings. Climb_stealth said it all really but here are some extra bits. The first one is a normal mode binding (the n in nnoremap). yiw copies the word you are currently on (without surrounding spaces), and then <C-r>" pastes that into the :Rg command. The :Rg command is part of the fzf vim plugin and it is a wrapper around ripgrep (see the link from climb_stealth), which gives you fuzzy search over the results of a ripgrep search. There is more detail on the <C-r>" command here: https://vim.fandom.com/wiki/Paste_registers_in_search_or_colon_commands_instead_of_using_the_clipboard https://vim.fandom.com/wiki/Paste_registers_in_search_or_col.... It's basically just how you paste the contents of registers into commands. The second one is almost exactly the same except that it is a visual mode mapping (the v in vnoremap). If you highlight something with visual mode, then use that command, it will search for the highlighted text using ripgrep. <C-Space> is just the key chord that the command is bound to. It is a pretty arbitrary personal choice, I find it a very quick and easy chord combination but you can put whatever you want in there. For example, <C-S> would activate the command when you pressed the chord 'control + s'. There is quite a good list of keys that are unused by vim here: https://vim.fandom.com/wiki/Unused_keys https://vim.fandom.com/wiki/Unused_keys You can pick whatever you want but I prefer not to override any of the default bindings. Hope that helps!
- mssundaram 6y agoVery helpful! Thank you for the great detail!