Skip to content

Instantly share code, notes, and snippets.

@romainl
Last active April 25, 2023 08:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romainl/eabe0fe8c564da1b6cfe1826e1482536 to your computer and use it in GitHub Desktop.
Save romainl/eabe0fe8c564da1b6cfe1826e1482536 to your computer and use it in GitHub Desktop.
Highlight characters after line 80
augroup TooLong
autocmd!
autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\%>80v', 100)
augroup END
@romainl
Copy link
Author

romainl commented Apr 25, 2023

I don't think you need the eval(), here. This should be enough:

'\%>' .. &tw .. 'v'

That said set tw=0 means that there is no line length limit for that buffer so a better approach would probably be to wrap the whole thing in a conditional:

  • if &tw > 0, highlight the characters after tw,
  • if &tw == 0, don't highlight anything as it doesn't make sense in that context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment