:match Todo /\%>80v.\+/
will highlight anything after virtual column 80 in the colors of the
Todo highlight group. (You may want to choose a different group if you
feel that Todo looks too much like Search.)
"Virtual" column so we count a hard tab as a variable number of columns,
not as one byte. Match "after 80" rather than "at 81" so even if a
modeline (or something) sets a weird 'tabstop' for a buffer, making tabs
straddle columns 80-81, the first character (if any) after column 80
will still match.
See
:help /ordinary-atom
:help /\%>v
Best regards,
Tony.
--
The Army needs leaders the way a foot needs a big toe.
-- Bill Murray
If, as I mentioned, some weird 'tabstop' setting (set, maybe, by a
modeline) causes tabs to straddle columns 80-81 (e.g. by having a file
with the following last line:
vim: ts=33
), whenever a tab straddles col.81 there will be no character sitting
exactly in column 81 on that line (in this case, let's say, a line with
three hard tabs then some text) and your single-column highlight will fail.
Also, AFAIK Vim cannot highlight in a special colour anything beyond the
end of the line, except of course the 'cursorcolumn' but I don't think
you would want to always keep your cursor in column 81. ;-)
Best regards,
Tony.
--
A man goes to a tailor to try on a new custom-made suit. The
first thing he notices is that the arms are too long.
"No problem," says the tailor. "Just bend them at the elbow
and hold them out in front of you. See, now it's fine."
"But the collar is up around my ears!"
"It's nothing. Just hunch your back up a little ... no, a
little more ... that's it."
"But I'm stepping on my cuffs!" the man cries in desperation.
"Nu, bend you knees a little to take up the slack. There you
go. Look in the mirror -- the suit fits perfectly."
So, twisted like a pretzel, the man lurches out onto the
street. Reba and Florence see him go by.
"Oh, look," says Reba, "that poor man!"
"Yes," says Florence, "but what a beautiful suit."
-- Arthur Naiman, "Every Goy's Guide to Yiddish"
Vim won't show you a margin line. Tony has said what Vim can do, but you might like
to read more details:
http://vim.wikia.com/wiki/Highlight_long_lines
FYI many Vim people go into a frenzy whenever something appears on the screen other
than their text (I'm one of those). You wouldn't believe the complaints that people
made when syntax highlighting was made the default.
John
Well, I think the option would definitely be useful, considering how
often people ask for guidelines, and how poor a substitute :match is.
On the other hand, it might be nice to instead fix up the behavior of
matches to be able to highlight empty text... If that were done, this
would be as simple as :match Error /\%80v/ - After all, I don't see
why anyone would want the behavior that matches currently give if they
highlight virtual columns with no text....
~Matt
Only long lines would continue past the guide line as well - and given
that the match overrides syntax highlighting, I'd rather only see it
highlighting just the one column, rather than losing syntax
highlighting for the rest of the line.
> Also, how can you tell if the line is empty, and a virtual column is
> being highlighted, or if you have a _lot_ of whitespace, so that the
> actual content of a line is beyond the edge of your window? I would
> probably continue with the current behavior given by matches, even if
> the suggested option becomes availabe.
The same way as you do it without matches, using 'list' and
'listchars'. For instance, I use:
:set list listchars=tab:▷⋅,trail:⋅,nbsp:⋅
which looks very nice in my chosen font.
> That being said...this would be a cool feature, useful to many people.
> I would not be adverse to its inclusion, even if I'd rarely use it
> myself.
~Matt
Or, for a lot of purposes, I quite like:
:call matchadd('Error', '\s\+$')
But that's a personal preference thing (and only for some languages/filetypes).
Al
> The same way as you do it without matches, using 'list' and
> 'listchars'. For instance, I use:
> :set list listchars=tab:▷⋅,trail:⋅,nbsp:⋅
> which looks very nice in my chosen font.
You might want to use this, instead:
if &encoding == "utf-8"
set listchars=eol:$,trail:·,tab:»·,extends:>,precedes:<
else
set listchars=eol:$,trail:-,tab:>-,extends:>,precedes:<
endif
Or some other setup that takes availiability of UTF-8 into
account.
On the topic of multiple(!) arbitrary vertical marker lines & syntax
highlighting that works on (too) long lines: Yes, please :)
Richard