> On Wed, Mar 24, 2010 at 9:52 PM, Edward L. Fox <edyfox@gmail.com> wrote:
> > On Thu, Mar 25, 2010 at 04:48, Joshua Swink <jswink@ucmerced.edu> wrote:
> >> I'm wondering why the word "template" is highlighted in vim in my
> >> Java code. Apparently "template" is not a keyword in the Java
> >> language. Vim is highlighting the word with a bright red
> >> background, the same as if I'd entered a syntax error.
> >
> > Because "template" is a widely used C++ keywords but is not used in
> > Java. In order to keep you from misusing some C++ keywords in Java,
> > Vim highlights those keywords as syntax error by default. They are:
> >
> > auto delete extern friend inline redeclared register signed sizeof
> > struct template typedef union unsigned operator
> >
> > If you really want to use them, say, as variable names, you can
> > disable this feature by adding:
> >
> > let java_allow_cpp_keywords = 1
> >
> > To your .vimrc
>
> Is C++ the only language whose keywords are considered verboten in
> Java?
>
> I'd be interested if you can point me to any discussions or writeups
> of this concept, as the justification isn't clear to me right now.
> Someone took the time to make it part of the vim package, so they must
> have felt it was very important.
>
From :help ft-java-syntax :
In order to help you write code that can be easily ported between
Java and C++, all C++ keywords can be marked as an error in a Java
program. To have this add this line in your .vimrc file:
:let java_allow_cpp_keywords = 0
So, it seems like the default is supposed to be 1, which seems
reasonable. (That is: the user must choose to turn those keywords into
errors.) The syntax file on my system appears to confirm that. (Line
126 sets it to 1 if it isn't set.) Perhaps your distribution made the
choice (mistake, IMO) to override that?
Otherwise, by default this shouldn't affect anyone and the help text's
justification seems reasonable.
--
Best,
Ben
--
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
To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
No comments:
Post a Comment