开发者

Tool for auto formatting or giving error in VIM

What are the plugnins for vim/gvim that can report about bad formatting esp C++ code and PLSQL code. Like:

  1. blank space after a line.
  2. line having character more than 80 (like 'match' does).
  3. void foo(int x,int y); then it will report forgot a space after ,
  4. And many more formatting errors like above.

Is there any 开发者_如何转开发standard practice for reporting the formatting of code before checking into CVS?


In my case, I have a series of syntax rules defined to make such things easy to spot.

highlight ImproperSyntax ctermbg=red guibg=red
au BufWinEnter * syn match ImproperSyntax /\s\+$\| \+\ze\t/  "Spaces at the end of lines or BEFORE tabs
au Filetype cpp,c syn keyword ImproperSyntax dynamic_cast "disallowed keyword
au Filetype cpp,c syn match ImproperSyntax /[^\n]\%$/  display "Last line should be blank
au Filetype cpp,c syn match ImproperSyntax /\t/ display "No tabs!
au Filetype cpp,c syn match ImproperSyntax /,\S/ display "comma always has a space
au Filetype cpp,c syn match ImproperSyntax /\%80v.*$/ "Highlight any characters passed column 80

An additional trick you can use is to incorporate all of these into a function (or list/dictionary), and display them as an error either on the statusline (my preference), or to the user as an error.

Regarding checking into CVS... I'm not sure about CVS, but SVN and hg (and presumably most other version control systems) can be instructed to execute a series of 'pre-commit hooks', before allowing you to commit. One of those could easily be programmed to scan for this same behavior (possibly with some sort of override symbol as well).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜