Re: Settings for vim for C programming?
On Fri, Oct 19, 2001 at 09:56:32PM -0400, dman wrote:
> On Sat, Oct 20, 2001 at 11:19:19AM +1000, mdevin@ozemail.com.au wrote:
> | On Thu, Oct 18, 2001 at 10:45:39PM -0400, dman wrote:
> | > Here's what I do:
> ...
> | > 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.
>
> You're welcome.
>
> | Before printing my assignment this time, I had done the set expandtab to
> | convert the tabs to spaces.
>
> Setting expandtab will only perform the conversion as you insert text.
> It doesn't change existing text. See the 'retab' command for that.
> Set expandtab, then run ":retab".
Oh yeah. You are right. That was what I did. It was a week ago now
and I forgot. but I do remember pouring over the vim help pages to find
the right command (:retab).
>
> | 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.
>
> With sw and sts set properly you interact with the text as if there
> were 4-space-tabs in the file, but really only spaces exist. It is
> just as convenient as using tabs, except you get to pick the
> indentation level. See also the "<<" and ">>" commands. They
> decrease and increase the indent level.
>
> | 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.
>
> Yeah, version 6 rocks.
>
> | > 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.
>
> It can be. Now that you have seen some more relevant commands and
> options you know where to start looking.
>
> Be sure and use the ^} and ^T commands while browsing the help. ^}
> jumps to a tag (for example, if the cursor is on a colored word) and
> ^T jumps back to the previous location in the tag stack. Tags are
Ohh Wow! I didn't know you could do that. That makes navigating the
help pages sooo much easier.
> really cool and helpful too. Install the 'exuberant-ctags' package
> and run ctags on your source files. Then try typing
> ":tag <function_name>" and see what happens. (You jump to the line
> the function starts on) The tags work for C++, Java, Python, and lots
> of other languages too.
Wow! Wow! Wow! Wow! That is soo excellent!
I just did: apt-get install exuberant-ctags
Then went to my assignment directory and did: ctags *
And tested it out. Pressing ^} and ^T works like a treat. I can jump
back and forth through my code and between different files, headers,
typedef and enumerated type definations etc.
What I used to do was have multiple xterms open at once so that I could
remember what each functions parameters were etc. This will make things
soo much easier. I wish I knew this before I did the 3 assignments for
this unit. But I am planning on taking a C++ course over Summer break
so I am glad to have found this out now.
>
> vim+bash (and the rest of a *nix system) makes for the best IDE I have
> seen so far.
>
Yeah. I was already a convert. Now even more so.
Thanks again.
Mark.
Reply to: