Sunday, May 23, 2010

Re: Highlighting whole lines depending on keywords

On 05/23/2010 03:55 PM, ThG wrote:
> Bonjour,
>
> I wish to use Vim to write a book. Plain text. But I am new to Vim...
>
> I want this book to be divided in "blocks", i.e. lines in Vim (some
> quite long, some very short like in a dialog between friends). Each
> block will correspond to a character (for example John, Chris and
> Emily) and that character only .You might thus have in succession :
> - John's "stream of consciousness"
> - Emily speaking on the phone
> - Chris interrupting both with a question
> - etc...
> It is important to note that the name of characters will not be
> indicated like in a play, but that I intend to place keywords such as
> [John] at the end of the lines, indications that I shall wipe out when
> it's finished. I want these keywords to allow me to highlight text
> differently, depending on who is concerned, in order to have a global
> view of their succession, like in a score, while the book is a WIP.
>
> My settings (MacVim, latest Vim release) are background=dark in
> my .vimrc
>
> I would like to have for example :
> - John (the main character) in "standard" lines, i.e. without
> highlighting : grey foreground (font : I hope I am not mistaken)
> - Emily : light blue foreground
> - Chris : light green foreground
> - etc...
>
> My questions are :
> 1. How do I create the list of the 3 keywords [John] [Emily] [Chris] ?
> 2. How do I highlight their lines differently, depending on the
> keyword I shall place at the end of the line ? And, btw, what happens
> if I put 2 keywords [John][Chris] by mistake ?
>
> Thanks in advance for the hand-holding.
> NB : Your help does not mean you will endorse any responsibility in
> the quality of the book ...
>
> ThG
>
>

I don't know very much about this, but I think this will work for you.
Put in your vimrc:

hi myhighlight guibg=grey30
syn match myhighlight '.*\[test\]'

This means any chars in line ending with [test].
-ak

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: