Editor Configuration

Some of the most obvious part of the Libav CodingStyle can be enforced by configuring your text editor.

The following suggested settings cover the commonly used editors, please extend the section with your favorite editor if it is missing.


You can put the following in your .vimrc.

" Indentation rules for Libav: 4 spaces, no tabs.
set expandtab
set shiftwidth=4
set softtabstop=4
set cindent
set cinoptions=(0
" Allow tabs in Makefiles.
autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8
" Trailing whitespace and tabs are forbidden, so highlight them.
highlight ForbiddenWhitespace ctermbg=red guibg=red
match ForbiddenWhitespace /\s\+$\|\t/
" Do not highlight spaces at the end of line while typing on that line.
autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@<!$/

If you want, you can configure your editor even more...


You may store the following in your .emacs.d/init.el.

(c-add-style "libav"
               (c-basic-offset . 4)
               (indent-tabs-mode . nil)
               (show-trailing-whitespace . t)
                (statement-cont . (c-lineup-assignments +)))
(setq c-default-style "libav")