Suppose I have \label{some text}
somewhere in my file and I want to store some text
into a variable.
Right now what I am doing to achieve this is to first visually select some text
and then store it in a register, say "p
. Then I run let g:var = @p
This does not feel right. What is a better way to do it.
If it was just one word that I wanted to store in a variable then let g:var = expand('<cword>')
does the job once the cursor is on that word. So I am able to avoid going to visual mode. But when there is a bunch of words involved I am looking for avoiding visual mode.