4 ms·
I must have bindings that are overriding what that should do, can you explain what <C-space> y and yiw should normally do?
by mssundaram 6y ago
I 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!