world leader in high performance signal processing
Trace: » vi

Development Tricks for Vi/Vim Users

Here are some helpful macros for highlighting common problems in source code (trailing whitespace for example). They are a bit tailored to the Linux kernel coding style, so you might have to adopt them to suite the project you're working on.

set nocompatible                        " vim defaults, not vi!
filetype on                             " automatic file type detection
set listchars=tab:>-,eol:$,trail:.,extends:#
syntax on
au Syntax *    syn match Error /\s\+$/ | syn match Error /^\s* \t\s*/ | syn match Error /^\t* \s*/hs=e | syn match Error /\%>80v.\+/
syn keyword cType uint ubyte ulong uint64_t uint32_t uint16_t uint8_t boolean_t int64_t int32_t int16_t int8_t u_int64_t u_int32_t u_int16_t u_int8_t
syn keyword cOperator likely unlikely
set noexpandtab                         " use tabs, not spaces
set tabstop=8                           " tabstops of 8
set shiftwidth=8                        " indents of 8
set textwidth=78                        " screen in 80 columns wide, wrap at 78
set autoindent smartindent              " turn on auto/smart indenting
set smarttab                            " make <tab> and <backspace> smarter
set backspace=eol,start,indent          " allow backspacing over indent, eol, & start
filetype plugin indent on