Reputation: 5249
The new c++ keyword constexpr is not highlighted by vim. I have tried plugins like this one: http://www.vim.org/scripts/script.php?script_id=4617
It worked very well for everything else except constexpr.
Does anyone know how I can turn syntax highlight on for constexpr in my cpp.vim (or by using other methods)?
Upvotes: 1
Views: 353
Reputation:
In vim 7.4 (and probably earlier, but 7.4 is what I have installed), constexpr
should be set up by the standard cpp.vim
file, which should be a part of your installation.
It is, however, guarded in a test for the cpp_no_cpp11
variable:
" C++ 11 extensions
if !exists("cpp_no_cpp11")
syn keyword cppType override final
syn keyword cppExceptions noexcept
syn keyword cppStorageClass constexpr decltype
syn keyword cppConstant nullptr
endif
You can :echo exists("cpp_no_cpp11")
; if the result is 1, that would explain why you don't see the highlighting (you'll have to diagnose your configuration to see why it's getting set, though).
Alternatively you can go for a brute force method and put
syn keyword cppStorageClass constexpr
in your .vimrc
(along with whatever other else you want; seems like you'll also be missing decltype
, et cetera). Or you can put the command in a script file that you load via autogroup
or using the "after" directory (like the plugin you linked) if you want to be gentler in your approach.
(Note that the plugin you linked doesn't attempt to add C++11 keyword highlighting at all, at least not for constexpr
. It's mostly concerned with functions and type names.)
Upvotes: 1