C++ string data type not highlighted like the other data types

1,064 views
Skip to first unread message

CyberZet

unread,
Sep 13, 2009, 3:04:43 PM9/13/09
to v...@vim.org
Hey there,

I'm writing C++ programs and the 'string' data type is not highlighted like all the other data types, can someone help me find the cause of this ?

Here is a sample of code : http://img16.imageshack.us/img16/8121/screenshotunsafeinttoch.png

Here is my colorscheme : http://www.mediafire.com/?odneeix4ewm

Here is my .vimrc file : http://www.mediafire.com/?hmdylmmymw9

I also have installed the CVim plugin.

Magnus Leuthner

unread,
Sep 13, 2009, 4:22:45 PM9/13/09
to vim...@googlegroups.com
>
> I'm writing C++ programs and the 'string' data type is not highlighted like
> all the other data types, can someone help me find the cause of this ?
>
> Here is a sample of code :
> http://img16.imageshack.us/img16/8121/screenshotunsafeinttoch.png
>
> Here is my colorscheme : http://www.mediafire.com/?odneeix4ewm
>
> Here is my .vimrc file : http://www.mediafire.com/?hmdylmmymw9

Same behaviour here, char is highlighted, string isn't. I assume this
is desired behaviour since string is strictly speaking not a
"built-in" atomic type that the compiler understands, it is a class
defined in the standard headers that are bundled with the compiler. I
assume the string type uses char internally, which is the actual type
the compiler understands and that vim highlights for this reason.

If vim highlighted every class defined somewhere in the C++ standard
library specification, I guess there'd be a lot of unwanted coloring
going on.

Just my guess.

Mac

CyberZet

unread,
Sep 13, 2009, 4:56:17 PM9/13/09
to vim...@googlegroups.com
It's because String isn't a C++ built-in data type, but a custom one declared in my header file in a class. Is there a way to highlight specific words in a colorscheme? Like in this case 'string' ?

Patrick Gen-Paul

unread,
Sep 13, 2009, 11:16:57 PM9/13/09
to vim...@googlegroups.com
CyberZet wrote:

>> It's because String isn't a C++ built-in data type, but a custom one
> declared in my header file in a class. Is there a way to highlight specific
> words in a colorscheme? Like in this case 'string' ?

I think you need a customized version the c.vim syntax file so that your
keyword, in the vim sense, is recognized, and then link it to a specific
highlight group.

:h syntax
:h syntax-highlighting

HTH

Gen-Paul.


Ben Fritz

unread,
Sep 13, 2009, 11:23:25 PM9/13/09
to vim_use


On Sep 13, 3:56 pm, CyberZet <rxcyb...@gmail.com> wrote:
> > It's because String isn't a C++ built-in data type, but a custom one
>
> declared in my header file in a class. Is there a way to highlight specific
> words in a colorscheme? Like in this case 'string' ?

We've got another thread going on right now about highlighting your
own keywords in your code. I'd suggest checking there.

http://groups.google.com/group/vim_use/browse_thread/thread/859609178d1b97f4
Reply all
Reply to author
Forward
0 new messages