[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Settings for vim for C programming?



On Thu, Oct 18, 2001 at 10:45:39PM -0400, dman wrote:
> Here's what I do:
> 
> -------------------------
> " Global defaults, applies to everything
> 
> syntax on
> 
> if version >= 600
>     filetype on
>     filetype plugin on
>     filetype indent on
> endif
> 
> set autoindent
> set tabstop=8                   " Tabs are always 8 characters!!!
> set softtabstop=4 shiftwidth=4  " default character indentation level
> set expandtab                   " use spaces instead of tabs for indentation
> set showmatch                   " show matching parens/brackets
> 
> " the following applies only to C source
> augroup C
>     au FileType c set sts=4 sw=4 tw=80 fo=croq
> 
>     if version >= 600
>         "au FileType c set foldenable foldmethod=indent
>         au FileType c set foldenable foldmethod=syntax
>         au FileType c syn region Block start="{" end="}" transparent fold
>         "au FileType c syn region Comment start="/\*" end="\*/" fold
>     endif
> augroup END
> 
> -------------------------
> 
> 
> 
> First I set some default values the way I want them for all buffers.
> Then I have a series of auto commands to set certian properties for
> certain buffer types.  For C programs, set the indent level
> (shiftwidth and softtabstop) to 4 spaces.  Also set the textwidth to
> 80 and set the formatoptions so my comments automatically are
> line-wrapped.
> 
> Version 6 has some neat new features including plugins and folding.
> The plugins I enabled so that when a C source file is opened, some
> good default options are set.  (this applies to other types as well)
> Folding is the ability to "collapse" a block of source into a single
> line of display.  This allows for better usage of vertical screen real
> estate.  I enable the folding so that the curly braces define a fold
> region.  Then 'zo' opens a fold and 'zc' closes a fold.

Thanks for all the info.  Very helpful and good explanations.

Before printing my assignment this time, I had done the set expandtab to
convert the tabs to spaces.  But then after I took it off 'cause I
thought it would be better to still be able to put tabs in.  But now I
can see that it just causes more headaches.

It seems that the best way is to get rid of the tabs all together and
make it put spaces instead like you have done above.  And like other
people suggested also.

I don't have version 6, but over Christmas, I am thinking about changing
to running woody, so I will get a chance to experiment with the folding
then.  Folding looks as though it really would help you "process" in
your mind a large amount of source code.
> 
> There are much more details in the help documents (type ":help
> <topic>").  
> 
I find it so hard to search through this help.  Especially when you
don't know what you are looking for in the first place.


Cheers and thanks for the information.

Regards.
Mark.



Reply to: