Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected red brackets highlight in vim

Tags:

c++

vim

In my C++ code vim shows red highlighted brackets in the following piece:

vim screenshot

This is some in-built functionality as I tried removing .vimrc, but it still shows them red. What's going on and how to fix it?

like image 527
sashkello Avatar asked May 20 '13 05:05

sashkello


People also ask

What does a red highlight in vim mean?

For example, vim can understand comments and highlight those texts in blue color and variables in green, etc… Similarly, errors are generally highlighted in red color and it looks like vim does not know how the syntax should be handled for /etc/sysconfig/named .

Why are my brackets red in C?

This means that the local parser has detected an unbalanced order of curly braces or parentheses. It's not perfect, however, as it can occasionally get confused, but it usually gets it right, and there may be compilation errors.

How do I enable highlighting in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.


1 Answers

Vim has only very limited C++ syntax highlighting capability built in. There is currently no support for C++11.

But there are, of course, plugins! Here's one that makes the error go away:

C++11 Syntax Support: A port of the existing C++ syntax to allow for C++11 features

To install, download the archive and extract the files into your ~/.vim/syntax directory. Enable the C++11 file type with :setf cpp11 or follow the instructions on the plugin home page.

like image 145
glts Avatar answered Sep 22 '22 18:09

glts