Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I expand a setting or variable in a vim regular expression?

Tags:

regex

vim

I have a regular expression, ^ \{3,}/, and want to use the value of a setting or variable in place of the 3. Here's the context:

match LeadingSpaces /^ \{3,}/
highlight LeadingSpaces ctermbg=red guibg=red

I'd like to use the value of tabstop in place of 3. Alternatively, I could set a new variable to be used.

like image 235
xn. Avatar asked May 15 '12 18:05

xn.


1 Answers

Try the following instead of match LeadingSpaces /^ \{3,}/:

execute 'match LeadingSpaces /^ \{'.&tabstop.',}/'
like image 131
Andrew Clark Avatar answered Oct 31 '22 20:10

Andrew Clark