Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I get the current visually selected text into a Vim variable or register?

0
Posted

How do I get the current visually selected text into a Vim variable or register?

0

register and then assigning the contents of the register into the variable: :normal! gvy :let myvar = @” The above command copies the visually selected text into the variable “myvar”. You can also use the command: :normal! gv”*y In the above command, gv reselects the last visually selected text and the rest of the command copies the selected text into the * (clipboard) register. Alternatively, you can set the ‘a’ flag in the ‘guioptions’ option to automatically copy a visually selected text into the * register. To do this as part of a visual map, you can use a command similar to the one shown below: :vmap “*y:call … For more information, read :help gv :help :normal :help let-@ :help quotestar :help clipboard :help registers 25.13. I have some text in a Vim variable ‘myvar’.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.