vim and Red Hat 9
Bob Bell
bbell at hp.com
Fri Jul 18 14:36:14 EDT 2003
On Fri, Jul 18, 2003 at 12:09:45PM -0400, Steven Knight <steven.knight at unh.edu> wrote:
> On Fri, 2003-07-18 at 10:56, Derek Martin wrote:
> > Anyone using vim to edit C code on a Red Hat 9 system? I'm finding
> > that the C-style auto-indenting has ceased to function, requiring me
> > to manually indent. Anyone else seeing this?
>
> The issue is that auto-indenting is not enabled unless you turn it on.
> You'll need to add to your .vimrc file ( or create this file )
>
> set autoindent
>
> You can find even more information about vim's indenting abilities with:
>
> :help C-indenting
The following is a subset of my vimrc as it relates to formatting
C files (just some ideas for you to look up in vim's help, which should
help you define your preferred style):
set autoindent " take indent for new line from previous line
set formatoptions=tcrq2l " how automatic formatting is to be done
set shiftwidth=4 " number of spaces to use for (auto)indent step
set shiftround " round indent to multiple of shiftwidth
set smarttab " use shiftwidth when inserting <TAB>
set noexpandtab " don't expand tabs [default]
set tabstop=8 " number of spaces that <Tab> in file uses [default]
function! s:ft_c()
set cindent
set cinoptions=(0,u0,t0,*50
iab <buffer> #i #include
iab <buffer> #d #define
endfunc
augroup bbell
au FileType c,cpp call s:ft_c()
augroup END
That's actually from my vimrc at work, which is probably more up-to-date
than my one at home, but I'm guessing it's also valid for Vim as shipped
on RH9.
--
Bob Bell <bbell at hp.com>
-------------------------------------------------------------------------
"Duct tape is like The Force. It has a light side, a dark side and
it holds the universe together."
-- Carl Zwanzig
More information about the gnhlug-discuss
mailing list