sponsor Vim development Vim logo Vim Book Ad

blockhl2.vim : Improved highlighting different levels of {} in C and C++ based on blockhl.vim

 script karma  Rating 1/3, Downloaded by 1362  Comments, bugs, improvements  Vim wiki

created by
Lord Bart
 
script type
syntax
 
description
This took vimscript#104 blockhi.vim and modified it for highlight the curly brackets using primary colors ie green red blue cyan yellow pink and also allowed for coloring the leading spaces (ie begin of line to first non spaces) instead of the whole code block between curly brackets.

I didn't like how blockhi.vim highlight the code part with background as grey.
I wanted only the leading spaces hilighted.
Also added filetype and load checking just to be realy safe.
Added cpp cluster group for cpp files.

It has two main functions:
HilightBrackets() truns on hilighting and hilight.
NoHilightBracktes() turns off hilighting clears syntax
has two toggle function with cab to run
toghib toggles the block hilighting on or off
toghibs toggles the leading space hilighting on or off but does not toggle block hilighting it self.
Colors cycle over if bracket level is more then Curly region were defined.

If you what more levels (it only has 6 right now) you can change by adding more bracket and lsp matches and more cCurly regions.
Just remember to have last bracket# set as hi bracket# guifg=NONE
and lsp# set  hi lsp# guibg=NONE were # is the one past highest color level.
This make sure you don't have all leading spaces in file hilighted all the time.

I have a way to highlight only the block your in, using a modified vimscript#626 ShowPairs.vim
But it not quite there yet.
I will mostly merge it in with this script since it uses some of this scripts members.
Coming soon.

 
install details
I created a other directory under ~/.vim and put this there ie ~/.vim/other/.
then in the ~/.vim/after/syntax dir I created a c.vim that source this file.
also created a link to c.vim as cpp.vim.
This was on a unix systems.
were ~/ is user's home dir.
file should be save in unix file format (ie no ^M's).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
blockhl2.vim 1.0 2003-06-16 6.0 Lord Bart Initial upload
ip used for rating: 18.220.160.216

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github