krabu wrote:
> I need to highlight lines in grey text color, if there is not the keyword
> "column" OR if there is the keyword "noshow". I want the whole line to be
> affected, but the keywords are not at the beginning of the line. 

One way to do it:
Add two highlight groups RegularLine, GreyLine:
:hilight RegularLine ctermbg=yellow
:hilight GreyLine ctermbg=grey

Add matches for the line you want, using priorities
" default: everything is GreyLine
:call matchadd("GreyLine", "^.*$", 5)
" ...except when 'column' appears anywhere on the line
:call matchadd("RegularLine, "^.*column.*$", 6)
" if 'noshow' is anywhere on the line, always stay GreyLine
:call matchadd("GreyLine, "^.noshow.$", 7)

This uses the priorities 5-7 to overrule previous matches.

In the following lines, only the line marked with (*) is RegularLine, all other
lines are GreyLine

line1
line2 column (*)
line3 column noshow

line1 is GreyLine, because there is no 'column'
line2 is RegularLine, because there is 'column'
line3 is GreyLine, because 'noshow' is on that line

> Another thing: is it possible to fold the affected lines? 

Not directly from the matches AFAIK, but you can write a fold expression:

:set foldmethod=expr
:set 
foldexpr=getline(v:lnum)=~'.*noshow.*'?1:(getline(v:lnum)=~'.*column.*'?0:1)

This will put every line that contains 'noshow' or not the keyword 'column' on
foldlevel 1, otherwise (keyword 'column' present, but not 'noshow') on foldlevel
0 (='not on a fold').

:set foldlevel=0

will fold the grey lines away.

-- 
Andreas.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to