I'd like to add ruler marks/virtual columns along the lines of
matchadd('ColorColumn', '\%81v', 100)
while restricting their display to the cursorline.
Any ideas ?
Try the following two commands:
" Match when cursor before column matchadd('ColorColumn', '\%#.*\zs\%81v', 100) " Match when cursor after column matchadd('ColorColumn', '\%81v\ze.*\%#', 100)
It should be possible to combine these into a single regular expression, but simply placing them into an alternation with
\| doesn't work correctly*, so doing so seems like more trouble than it's worth.
These work by finding the cursor position
\%# either following or followed by the specified column, but excluding everything apart from the column from the match with
* At a guess, there may be some complexity in the interaction between
\ze and alternation that I'm unaware of—you might have better luck with lookahead
\@= and lookbehind
\@<=, but note that these are inefficient compared to