Reputation: 120
The following command yanks the text delimited by ##'s and save it to buffer a
:
:?##?;/##/y a
This looks for the first previous and next occurrences of the delimiter. But I want to generalize this to any delimiter. I was thinking about defining a variable with
let g:delimiter = "#another_delimiter"
But I don't know how to access that value to do something like
:?\=g:delimiter?;/\=g:delimiter/y a
Do you guys have any suggestion?
Upvotes: 1
Views: 202
Reputation: 196751
If you are doing this on the command-line, you can insert the value of a variable with <C-r>=variable
:
:?<C-r>=g:delimiter<CR>?,/<C-r>=g:delimiter<CR>/y a
If you are doing this in a script, you should use string concatenation instead:
execute ":?" . g:delimiter . "?,/" . g.delimiter . "/y a"
Upvotes: 2