Mohsin wrote:
I want to use a highlighter mode on my text file, example:
:color_region bold line1 col1 line2 col2
:color_region bold 5 5 6 6
:color_region underline 5 5 6 6
I couldn't do this in vim. Vim only has syntax coloring with regexps.
Emacs has functions to apply properties to text blocks, and I was hoping
vim has something comparable.
tia.
m
Vim regexps allow you to specify line and/or column numbers. Example, to
match a block defined by lines 55 to 77, virtual columns 15 to 37, and
highlight it in bold-underlined text:
(untested)
:highlight User1 term=bold,underline cterm=bold,underline
gui=bold,underline
:match User1 /^\%55l\_.*\%77l$\&\%>14v.*\%<39v/
(these are two commands, each on one line). The pattern means "(from the
beginning of line 55, anythyng including line breaks, up to the end of
line 77) *and* (from after virtual comumn 14, anything but line breaks,
as much as possible, followed by a zero-length match before column 39)".
I _think_ this is the correct phrasing but you should test it. The
"after column" and "before column" matchings are used to avoid problems
if the exact columns in question are, let's say, halfway a tab. IIUC,
the rightmost column that can be included in "a zero-length match before
column 39" is column 37.
Best regards,
Tony.