[lug] Vi and Bracket Indenting

Sean Reifschneider jafo at tummy.com
Tue Oct 11 23:53:53 MDT 2005


On Tue, Oct 11, 2005 at 05:48:09PM -0600, Bill Thoen wrote:
>int test()
>{
>          /* codes starts way out here */
>}
>
>but what I want is an indent of one tab, set to about 2 or 4 spaces.

You will need the following things in your vimrc:

   set autoindent
   set tabstop=3
   set shiftwidth=3
   set softtabstop=0
   set smarttab
   set noexpandtab

That leaves tabs as tabs, sets the tab and shift to 3, and disables soft
tabs.  These are settings I use when I'm editing C and similar code.  I
have it automatically apply them when I'm editing C code by doing:

      autocmd FileType c set tabstop=3 shiftwidth=3 softtabstop=0 smarttab noexpandtab nolist textwidth=0

That requires that "filetype plugin indent on" be set, I believe.  For
other files that I don't list a FileType autocmd for, I tend to use
expandtab, autoindent, and set tw=78, so I get auto-wrap when I'm entering
e-mail text.

Thanks,
Sean
-- 
 Imagine what it would be like if TV actually were good. It would be the
 end of everything we know.  -- Marvin Minksy
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability




More information about the LUG mailing list