转一封邮件,说明怎样在vim中使多个关键字高亮显示
时间:2010-06-30 来源:zhangjiakouzf
On 30/05/08 05:50, googler wrote:
> On May 27, 7:49 pm, Tony Mechelynck<[email protected]>
> wrote:
>> On 28/05/08 02:43, Tony Mechelynck wrote:
>>
>>
>>
>>
>>
>>> On 24/05/08 20:59, googler wrote:
>>>> I would like to search for a particular string, say "abcd" and have
>>>> their occurences colored with red. Next I would like to search for
>>>> another string, say "wxyz" and have their occurences colored with
>>>> another color, say yellow. After the second pattern is found, the
>>>> first pattern should still remain colored. How can this be done in
>>>> vim? Thanks.
>>> :help :match
>>> :help :2match
>>> :help :3match
>>> :help matchadd()
>>> :help matchdelete()
>>> :help clearmatches()
>>> Note: The latest search pattern is in "register slash", so you can use
>>> :match ^R/
>>> (where ^R means "hit Ctrl-R) to "remember" the currently highlighted
>>> search before doing a new search. (Similarly with :2match but beware
>>> that :3match is used by bracket matching).
>>> Best regards,
>>> Tony.
>> Oops! That should have been
>>
>> :match /^R//
>>
>> Best regards,
>> Tony.
>> --
>
> On doing :match /^R// , I get "E28: No such highlight group name: /
> abcd/". Is there anything else I need to set? Thanks.
Looks like I was low on black tea when I made these previous posts:
hypotheinaemia is one of the main causes of erroneous posts with me.
Well: between the ":match" command-name and the /pattern/ you need the
name of a highlight group. For the same colors as the current search
pattern use
:match Search /^R//
For a red abckground as when syntax errors are found, use
:match Error /^R//
etc.
To see all the highlight groups currently defined in your Vim session
and how they are colored, use
:hi
Best regards,
Tony.
--
DENNIS: Oh, very nice. King, eh! I expect you've got a palace and fine
clothes and courtiers and plenty of food. And how d'you get
that? By
exploiting the workers! By hanging on to outdated imperialist dogma
which perpetuates the social and economic differences in our
society!
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
> On May 27, 7:49 pm, Tony Mechelynck<[email protected]>
> wrote:
>> On 28/05/08 02:43, Tony Mechelynck wrote:
>>
>>
>>
>>
>>
>>> On 24/05/08 20:59, googler wrote:
>>>> I would like to search for a particular string, say "abcd" and have
>>>> their occurences colored with red. Next I would like to search for
>>>> another string, say "wxyz" and have their occurences colored with
>>>> another color, say yellow. After the second pattern is found, the
>>>> first pattern should still remain colored. How can this be done in
>>>> vim? Thanks.
>>> :help :match
>>> :help :2match
>>> :help :3match
>>> :help matchadd()
>>> :help matchdelete()
>>> :help clearmatches()
>>> Note: The latest search pattern is in "register slash", so you can use
>>> :match ^R/
>>> (where ^R means "hit Ctrl-R) to "remember" the currently highlighted
>>> search before doing a new search. (Similarly with :2match but beware
>>> that :3match is used by bracket matching).
>>> Best regards,
>>> Tony.
>> Oops! That should have been
>>
>> :match /^R//
>>
>> Best regards,
>> Tony.
>> --
>
> On doing :match /^R// , I get "E28: No such highlight group name: /
> abcd/". Is there anything else I need to set? Thanks.
Looks like I was low on black tea when I made these previous posts:
hypotheinaemia is one of the main causes of erroneous posts with me.
Well: between the ":match" command-name and the /pattern/ you need the
name of a highlight group. For the same colors as the current search
pattern use
:match Search /^R//
For a red abckground as when syntax errors are found, use
:match Error /^R//
etc.
To see all the highlight groups currently defined in your Vim session
and how they are colored, use
:hi
Best regards,
Tony.
--
DENNIS: Oh, very nice. King, eh! I expect you've got a palace and fine
clothes and courtiers and plenty of food. And how d'you get
that? By
exploiting the workers! By hanging on to outdated imperialist dogma
which perpetuates the social and economic differences in our
society!
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
相关阅读 更多 +
排行榜 更多 +

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0526/1748214895997494.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0526/1748214895997494.png" alt="机器人狙击手最新版" />
飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0526/1748213241693464.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0526/1748213241693464.png" alt="我的枪有子弹最新版" />
飞行射击 下载- 4 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0525/1748174029364713.jpg" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0525/1748174029364713.jpg" alt="战斗地带汉化版" />下载58.6 MB · 94℃
1970-01-01
- 5 <img preview="http://pic.pdowncc.com/uploadimg/img/2025/0526/1748208215706549.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/img/2025/0526/1748208215706549.png" alt="超级兔子人联机版手机版" />下载45.51 MB · 96℃
1970-01-01
- 6 <img preview="http://pic.pdowncc.com/uploadimg/img/2025/0526/1748208215706549.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/img/2025/0526/1748208215706549.png" alt="超级兔子人联机版手机版" />下载169.80 MB · 95℃
1970-01-01