Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to copy a consecutive set of none empty characters in vim

Tags:

vim

${BASE}/test/  other_consecutive_none_empty_characters

If the cursor is under the $ sign ,how can I copy "${BASE}/test/" as a whole and paste it somewhere else in vim ? I don't want to use the human-eye-letters-counting solution if that is the only solution I'd rather like to hit the keyboard charcter by charcter .

like image 626
Haiyuan Zhang Avatar asked Jan 26 '26 21:01

Haiyuan Zhang


2 Answers

yE would be the most correct solution. y means "yank" (i.e. copy to buffer), and E - "up to the end of the WORD", which is, up to the next whitespace character.

Personally, I prefer typing yiW - yank inner WORD. It works the same way, but the cursor may reside anywhere inside the WORD, not just on the dollar sign.

like image 73
P Shved Avatar answered Jan 29 '26 11:01

P Shved


y Yank W WORD:

yW

From :help W:

A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a WORD.

like image 20
John Kugelman Avatar answered Jan 29 '26 13:01

John Kugelman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!