Last active
April 25, 2023 08:04
-
-
Save romainl/eabe0fe8c564da1b6cfe1826e1482536 to your computer and use it in GitHub Desktop.
Highlight characters after line 80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup TooLong | |
autocmd! | |
autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\%>80v', 100) | |
augroup END |
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 aftertw
, - 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
I made this variable by replacing the second argument of
matchadd
with'\%>' .. eval('&tw') .. 'v'
. This way, it respects whatever the user has set to be their text width.…but I quickly reverted that when I went into a
.md
file which hastw=0
in my config.I guess a smart way would be a function which uses a default number when the set text width is either not set or zero, else respect the already set text width.