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

Settings for vim for C programming?



Earlier I set my tabstop to 4 to give me some more screen room in my C
program .c files.  The problem is that when I print out the source code
(eg. for a Uni assignment) or when someone else edits it, the tabstops
are by default 8 spaces.

What is the best way to deal with this?

What I have currently in my /etc/vimrc is the following:
"""""""""""""""""""" C programming stuff """""""""""""""""""""""""""""""
syntax on               "syntax highlighting
"set tabstop=4  (default is 8)
set softtabstop=4
set shiftwidth=4
set pastetoggle=<F4>

So you can see that I have commented out the previous tabstop setting of
4 so that the default is now active, but have added the softtabstop=4
option and left shiftwidth=4.

I think that this adds 4 spaces when you press tab.  And if an automatic
indentation occurs (while writing c source code), it will add 4 spaces
if the indentation is less than 8 spaces from the side or a combination
of tabs and spaces if the indentation is more than 8 spaces from the
side.

Is this correct?  If not how do you do it properly?

How do all you guys do it?  Basically, I just want my source code, to look
to everyone else, as it looks to me, when they edit it, or I print it out.
But I want to be able to use more of the screen by using tabspaces of 4.

Thanks for the help.

Regards.
Mark.



Reply to: