Version 3 (modified by 15 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 that will set up the w:created variable (vim tip 1598) " so we can run the check only once per window 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', 'select(', -1) call matchadd('ErrorMsg', 'while(', -1) call matchadd('Search', '[a-z-A-Z0-9][,=/+\-*;][a-zA-Z0-9]', -1) " operator with no space around it call matchadd('Search', '[,=/+\-* ]$', -1) " operator or whitespace at end of line :endfu " 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.