wiki:CodingGuidelines/VIM

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.

http://cgit.haiku-os.org/haiku/plain/3rdparty/pulkomandy/checkstyle.vim

Calling the function

The obvious way to enable the script is to do it by hand :

:call FuncHaikuCheck()

It is also possible to make it run on every opened file (this is a bit annoying when using vim for something else than Haiku or C++ files)

" 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

" call the function on all opened files
autocmd WinEnter * if !exists('w:created') | call FuncHaikuCheck() | endif
autocmd BufWinEnter * call FuncHaikuCheck()

The last option is to define a keyboard shortcut to enable it (control+F3 in this example) :

map <C-F3> :call FuncHaikuCheck()<CR>

These rules have been ported to a standalone python program see the Style Checker Tools paragraph in the Haiku coding guidelines and src/tools/checkstyle/

Last modified 10 years ago Last modified on Aug 7, 2014, 11:21:32 AM
Note: See TracWiki for help on using the wiki.