0

This highlights the parts of the lines that are over 80 columns long:

augroup over_length
    autocmd!
    autocmd BufEnter * highlight OverLength ctermbg=darkgrey
    autocmd BufEnter * match OverLength /\%80v.*/
augroup END

However, I would like to modify it to use &textwidth. Using /\%.&textwidth.v.*/ doesn't seem to work. Is there a way to substitute the value into the regular expression?

2
  • My want to consider using set colorcolumn=80. See :h 'cc' Feb 22, 2017 at 18:03
  • @PeterRincker I find colorcolumn too distracting.
    – user8048
    Feb 23, 2017 at 18:06

1 Answer 1

2

Yes, you have to use execute and put it in a string:

execute 'match OverLength /\%'. &textwidth .'v.*/'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.