[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-ia64-devel] Re: vimrc snippet
Since I received two encouraging replies to my last post, and since Alex mentioned to me that the snippet can cause some confusing results without further vim configuration, here is a more complete configuration for general C coding. This can be cut-n-pasted directly into .vimrc " Tabs and indents set autoindent " maintain current indent on newline set shiftround " round indent < and > to multiple of shiftwidth set shiftwidth=4 " but see override in c_linux-kernel.vim set smarttab " use shiftwidth when inserting <Tab> set tabstop=8 " number of spaces that <Tab> in file uses " Important for working in hardlinked trees (e.g. git or mercurial) set bkc+=breakhardlinks " always break hardlinks when writing " Load filetype plugins filetype plugin indent on if has("syntax") syntax on endif " Default options for C files autocmd FileType c,cpp let b:c_gnu=1 " highlight gcc specific items autocmd FileType c,cpp let b:c_space_errors=1 " highlight trailing w/s and spaces before tab autocmd FileType c,cpp let b:c_no_curly_error=1 " don't highlight {} inside () autocmd FileType c let g:c_syntax_for_h=1 " use C highlighting for header files if has("cindent") autocmd FileType c,cpp setl cin cino=(0,u0,t0,l1 " see :help cinoptions-values endif " Match precedent in file for tabs/spaces indentation autocmd FileType c,cpp \ let tabre = '^\t\|^\( \{8}\)' | \ let foundtab = v:version >= 700 ? \ search(tabre, 'cnpw', 1000) : search(tabre, 'cnpw') | \ if foundtab == 1 | setlocal noexpandtab | \ elseif foundtab == 2 | setlocal expandtab | endif Additionally, I have two filetype plugins for working in the Linux kernel and working in Xen. These set the shiftwidth (4 for xen, 8 for Linux), include path (for example, for "gf"), tags location (use "make tags" at the top level) and cscope database (use "make cscope" at the top level). $ mkdir ~/.vim/ftplugin $ cd ~/.vim/ftplugin $ wget http://n01se.net/agriffis/skel.hg/?raw-file/tip/vim/ftplugin/c_linux-kernel.vim $ wget http://n01se.net/agriffis/skel.hg/?raw-file/tip/vim/ftplugin/c_xen.vim I'd appreciate any feedback. Thanks, Aron _______________________________________________ Xen-ia64-devel mailing list Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ia64-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |