Vim Tips Wiki
No edit summary
(Change <tt> to <code>, perhaps also minor tweak.)
 
(One intermediate revision by one other user not shown)
Line 27: Line 27:
 
</pre>
 
</pre>
   
This doesn't work in all cases (for instance, it doesn't highlight constructors using an initialization list on the same line) but it shouldn't highlight function calls (such as <tt>MyClass::MyStaticMethod( int foo );</tt> )
+
This doesn't work in all cases (for instance, it doesn't highlight constructors using an initialization list on the same line) but it shouldn't highlight function calls (such as <code>MyClass::MyStaticMethod( int foo );</code> )
   
 
==See also==
 
==See also==
Line 36: Line 36:
   
 
----
 
----
 
 
[http://www.vipsexshop.com.br Sex Shop]
 
[http://www.requintesexshop.com.br Sex Shop]
 
[http://www.sexshop.com.vc Sex Shop]
 
[http://www.belasexshop.com.br Sex Shop]
 
[http://www.belasexshop.com Sex Shop]
 
[http://blog.vipsexshop.com.br Dicas de Sexo]
 
[http://www.viplingerie.com.br Lingerie]
 
[http://www.vipcalcinhas.com.br Calcinhas]
 
[http://www.uniformesbr.com Uniformes Profissionais]
 
[http://www.uniformesbr.com Uniformes]
 

Latest revision as of 05:40, 13 July 2012

Tip 641 Printable Monobook Previous Next

created 2004 · complexity basic · author Olivier Teuliere · version 6.0


When editing big cpp files, it can be very convenient to highlight the method name (the part after "::") in a method definition.

I use the following function in my vimrc:

" Add highlighting for function definition in C++
function! EnhanceCppSyntax()
  syn match cppFuncDef "::\~\?\zs\h\w*\ze([^)]*\()\s*\(const\)\?\)\?$"
  hi def link cppFuncDef Special
endfunction

I have another line to call this function automatically when editing a C++ file:

autocmd Syntax cpp call EnhanceCppSyntax()

This doesn't work in all cases (for instance, it doesn't highlight constructors using an initialization list on the same line) but it shouldn't highlight function calls (such as MyClass::MyStaticMethod( int foo ); )

See also[]

Comments[]

To further facilitate adding user-defined extensions to existing syntax files, you can use a ".vim/after/syntax/" directory. See :help mysyntaxfile-add.