how to display different color in vi

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

how to display different color in vi

skyworld
Hi,

normally I use gvim instead of vi. My question is for gvim is: can i use different color to show diffent word?  For example, I would like to highlight word "red" with red and "yellow" with color yellow in one document. Is this possible?  thanks





--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: how to display different color in vi

JohnBeckett
skyworld wrote:
> normally I use gvim instead of vi. My question is for gvim is:
> can i use different color to show diffent word?  For example,
> I would like to highlight word "red" with red and "yellow"
> with color yellow in one document. Is this possible?

The tip for that is:
http://vim.wikia.com/wiki/Highlight_multiple_words

It can be done manually to a limited extent. In the following,
"Search" and "Error" are highlight groups that should be
displayed by default with the ":highlight" command.

    :match Search /\<yellow\>/
    :2match Error /\<red\>/

To switch highlighting off:

    :match none
    :2match none

John


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

skyworld
Hi John,

thanks for your help. I have tried several times, but always failed.

1. I first tried to set "abc" in my file to be red as:

:match abc /\<yellow\>/

the system seems to be idle and there is no response.

2. I checked help with "match" command and tried its example:

:highlight abc ctermbg=green guibg=green
:match abc /\<red\>/

still there is no reponse.

could you give me some timps? thanks.






在 2014年12月24日星期三UTC+8下午7时08分01秒,JohnBeckett写道:

> skyworld wrote:
> > normally I use gvim instead of vi. My question is for gvim is:
> > can i use different color to show diffent word?  For example,
> > I would like to highlight word "red" with red and "yellow"
> > with color yellow in one document. Is this possible?
>
> The tip for that is:
> http://vim.wikia.com/wiki/Highlight_multiple_words
>
> It can be done manually to a limited extent. In the following,
> "Search" and "Error" are highlight groups that should be
> displayed by default with the ":highlight" command.
>
>     :match Search /\<yellow\>/
>     :2match Error /\<red\>/
>
> To switch highlighting off:
>
>     :match none
>     :2match none
>
> John
--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

Loïc Lefloch
In reply to this post by skyworld
Hello,

There is this plugin : https://github.com/gorodinskiy/vim-coloresque

Maybe it can help you

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

Sven Guckes-3
In reply to this post by skyworld
* skyworld <[hidden email]> [2014-12-25 10:52]:
> I have tried several times, but always failed.
> :match abc /\<yellow\>/
> :highlight abc ctermbg=green guibg=green
> :match abc /\<red\>/

here we go..

  :syn match yellow "\<yellow\>"
  :hi        yellow ctermbg=yellow guibg=yellow
  :syn match red    "\<red\>"
  :hi        red    ctermbg=red    guibg=red

save this to eg   red_and_yellow.vim
and then ":source red_and_yellow.vim"

see also:
    :view $VIMRUNTIME/syntax/colortest.vim
    :source %

Sven

--
http://www.guckes.net/vim/syntax/sven.vim

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

Marcin Szamotulski-2
In reply to this post by skyworld
On 01:12 Thu 25 Dec     , skyworld wrote:

> Hi John,
>
> thanks for your help. I have tried several times, but always failed.
>
> 1. I first tried to set "abc" in my file to be red as:
>
> :match abc /\<yellow\>/
>
> the system seems to be idle and there is no response.
>
> 2. I checked help with "match" command and tried its example:
>
> :highlight abc ctermbg=green guibg=green
> :match abc /\<red\>/
This works perfectly fine for me.  Maybe you have a tiny build without
+syntax; check the output of `echo has('syntax')`.

Best regards,
Marcin

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

skyworld
In reply to this post by skyworld
Thank you everyone for your kind help. Until now I only succeeded in Sven's method.

I guess what I should do in the future is:

:syn match search_pattern "\<search_pattern\>"
:hi search_pattern ctermbg=color guibg=color

Is this correct? thanks



在 2014年12月24日星期三UTC+8下午5时14分02秒,skyworld写道:
> Hi,
>
> normally I use gvim instead of vi. My question is for gvim is: can i use different color to show diffent word?  For example, I would like to highlight word "red" with red and "yellow" with color yellow in one document. Is this possible?  thanks

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to display different color in vi

Charles Campbell
In reply to this post by skyworld
skyworld wrote:

> Hi John,
>
> thanks for your help. I have tried several times, but always failed.
>
> 1. I first tried to set "abc" in my file to be red as:
>
> :match abc /\<yellow\>/
>
> the system seems to be idle and there is no response.
>
> 2. I checked help with "match" command and tried its example:
>
> :highlight abc ctermbg=green guibg=green
> :match abc /\<red\>/
>
> still there is no reponse.
>
> could you give me some timps? thanks.
>
* its  :match {group} /{pattern}/
  (try using  :help :match)

  I seriously doubt that you've set up a highlighting group by the name
of "abc" if, in fact, that's what you tried.  Try using something
sensible; say  :match Error /\<yellow\>/ .  Its not likely to be yellow,
though, but it'll give you the idea.
  To set up color groups (red, yellow, ...), here's an example:

  hi Yellow       start= [m [33m      stop= [m [32m      
cterm=NONE      ctermfg=14      guifg=yellow   guibg=navyblue

  With that, you could use   :match Yellow /\<yellow\>/

* Its possible your vim does not support highlighting; for example,
perhaps not if its the tiny build.  If the above doesn't work, then use

   :version

  Under "Compiled by..." is a line that will say
[Huge|Big|Normal|Small|Tiny] version..."

That command will tell you/us what you've got.

* You could try http://www.drchip.org/astronaut/vim/index.html#HIGHLIGHT
and get the highlight.vim plugin.  Place cursor over something and press
"*" on the numeric keypad to get that something highlighted.

Regards,
Chip Campbell


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.