On Fri, Oct 19, 2001 at 12:15:43PM +1000, [EMAIL PROTECTED] wrote: | 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.
Yep. | What is the best way to deal with this? Tabs are 8 spaces. Period. Learn to live with it. (my opinion, Will Trillich, for one, disagrees) | 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. Yes, that is good. | 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. You got it. | Is this correct? Is it what you want? Most people would say NO. Never mix tabs and spaces -- it is a recipe for disaster (or headaches at least). | If not how do you do it properly? | | How do all you guys do it? Well, I do it properly, of course <wink>. You want to set 'expandtab' too so that all tabs are expanded to spaces. Then you will get spaces and only spaces and everything will work nicely. | 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. s/tabspaces/indentation level/ Don't get stuck in the low-level details. 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. There are much more details in the help documents (type ":help <topic>"). HTH, -D