On Mon, Feb 21, 2011 at 7:23 AM, Hugh Sasse <hgs@dmu.ac.uk> wrote:
I've been assisting a colleague with their C code, and he has
learned to add semicolons at the end of statements too well. His
current favourite mistake is to write
if (expression == value);
{
do_something();
};
I frequently miss the trailing semicolon on the first line. So I
was wondering if it would make sense to modify the C syntax file to
highlight
if (expr);
such that the semicolon shows up as an error. Clearly it is a legal
null statement, and so is syntactically correct. But if one only
wanted the expr for its side effects, one would not need to put it
in an if. To do this because one is only using the else part is
poor communication with other programmers.
Is there a good reason not to change the syntax file? Otherwise,
can anyone suggest a patch: my skills in this area are suboptimal,
as I don't change syntax files very often.
Thank you
Hugh
If you only concern about the semicolon after if statements,
you can try add following to your vimrc file:
autocmd BufEnter *.c match Grp_semi /if\s*(.\+)\s*;/
highlight Grp_semi guibg=red
This will highlight the if statement with red background if he put semicolon after a if statement.
--
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
No comments:
Post a Comment