Tony Mechelynck wrote:
> On 17/11/09 16:55, Jürgen Krämer wrote:
>>
>> Hi,
>>
>> Yogi wrote:
>>> I want to be able to highlight bold, italics, and underlined words in
>>> a text file. My solution was to use
>>>
...snip...
>>>
>>> Any ideas how I can do it? Do I need to write a syntax file for this?
>> you can define up to 3 different matches by prefixing the match-command
>> with numbers 1, 2, and 3, respectively:
>>
>> hi QuickBold gui=bold
>> hi QuickItalic gui=italic
>> hi QuickUnderline gui=underline
>>
>> 1match QuickBold /\*\zs.\{-}\ze\*/
>> 2match QuickItalic /\/\zs.\{-}\ze\//
>> 3match QuickUnderline /_\zs.\{-}\ze_/
>
> However, beware that :3match is already used by the matchparen plugin,
> so if you want to use it for another purpose you had better do
>
> :NoMatchParen
>
> first (if already started), or
>
> :let loaded_matchparen = 1
>
> (if in the vimrc).
While the :match commands work reasonably well for this simple case, the
approach is somewhat limited. For one thing, it doesn't permit *nesting*
of highlight attributes. You could not use it, for example, to italicize
a block of text, and embolden only certain words within the block. Nor
could you create a block of red text on a blue background, with
bold-underline-italic text within the region. (Well, ok, perhaps you
wouldn't *want* to create a block so garish... But you get the idea. ;-)
One of the advantages of the Txtfmt plugin for this sort of highlighting
is that you can highlight arbitrary blocks of text with *any*
combination of fg/bg colors and format attributes: basically, it's like
having a sort of "rich text" capability for plain text in Vim.
http://www.vim.org/scripts/script.php?script_id=2208
It should also be pointed out that the :match strategy shown above would
*always* italicize something within /.../. This may or may not be what
is desired; if, for example, you were documenting some pathnames, or a
sed or perl command, the /.../ might simply be part of the text, and not
intended as markup at all. Similarly, underscores are used quite
frequently in some textual contexts; consequently, the strategy outlined
above may occasionally result in unintentional highlighting of text.
Although Txtfmt's highlighting is also token-based, you can configure
the range of characters used as tokens; for utf-8, the default range is
in Unicode's "Private Use Area", which means you needn't worry about the
tokens being used for any other purpose. (Of course, there's no need to
remember the actual characters used, since Txtfmt provides a very
intuitive mechanism for specifying the desired highlighting.)
Sincerely,
Brett Stahlman
.
.
>
> Best regards,
> Tony.
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php