I'm aware that I can use / followed by a regex to search something. And I can use ? to search backwards. And I can use n and N to repeat the search forward and backward.
There are also two nice shortcuts: * or # will search for the word under the cursor (forward/backward). That's very useful! (there are also g* and g# variants)
But... Once I've selected text using visual mode (v), how can I ask Vim to search for exactly that text? A quick look at :help
did not... huh... help me.
*
and#
! Would be nice if your question would also explain whatg*
andg#
would do ;)g
character means that you want to search for the same word on any other tab that you have opened in the same VIM session/window.g*
/g#
means that a match doesn't have to be a whole word (less strict), whereas*
/#
only matches the whole word (more strict). docs For example, usingg*
when the cursor is on the wordtest
will result in the command/test
which would match the first four letters in the wordtesting
. Using*
will result in the command/\<test\>
, notice the added angle brackets, which means it must match the whole wordtest
therefore it will not matchtesting
likeg*
would.