Version 1 (modified by mmadia, 14 years ago) ( diff )


Here is a small script that will detect some guideline violations for vim. I put it in my .vimrc and it highlight all the errors it can find in all opened files. I'd like to know if you made improvements on it.

autocmd QuickFixCmdPost make cw

" autocmd that will set up the w:created variable (vim tip 1598)
autocmd VimEnter * autocmd WinEnter * let w:created=1

:fu FuncHaikuCheck()
       call matchadd('ErrorMsg', '\%>80v.\+', -1) " More than 80 chars on a line
       call matchadd('ErrorMsg', '  ', -1) " Two spaces (likely wrong indentation)
       call matchadd('ErrorMsg', 'for(', -1) "for without space
       call matchadd('ErrorMsg', 'if(', -1) " if without space
       call matchadd('ErrorMsg', 'while(', -1) " while without space

" call the function on all opened files
autocmd WinEnter * if !exists('w:created') | call FuncHaikuCheck() | endif
autocmd BufWinEnter * call FuncHaikuCheck()
Note: See TracWiki for help on using the wiki.