For example
test test word
Currently the cursor is under word
, and I want to search by word
, normally I would do select word
and copy it. then type :/
and paste and return.
Is there any shortcut for this?
You can use * and/or # to search for the word under the cursor or viw to visually select the word under the cursor.
Press Esc to cancel or press Enter to perform the search. Then press n to search forwards for the next occurrence, or N to search backwards. Type ggn to jump to the first match, or GN to jump to the last.
To find a character string, type / followed by the string you want to search for, and then press Return. vi positions the cursor at the next occurrence of the string. For example, to find the string “meta,” type /meta followed by Return. Type n to go to the next occurrence of the string.
Use *
to search forward and #
to search backward, for the word under the cursor. Once you initiate the search, you can use n
to repeat it in the same direction or N
in the reverse direction. Or else use *
or #
again from the word that you landed on.
The *
and #
commands basically initiate searches as if you used /\<word\>
or ?\<word\>
. Thus these searches can be recalled with up arrow at the /
or ?
search prompt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With