Linux - GeneralThis forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am looking for a vim plugin that could hide or shrink block comments. For example, a block comment would be something like this:
/* ------------------------------------------------------------------------------------------------
Function: void print(string s)
Descript: prints input string message to the standard output and if logging is enabled, writes the messages to the log file
Programmer: John Doe
Version: 0.0.1
Called By: int main(int argc, char* argv[])
Calls To:
Input: standard 128-key keyboard
Output: writes to similarity vector, color-frequencies array
Parameters:
Returns: true if there were no problems processing the images, false if there was a problem with the image dimensions.
0.0.1 06/14/2006 C.D.
Wrote the function
------------------------------------------------------------------------------------------------ */
void print(string s)
{
// code
}
I would like the plugin to make it look something like this:
/* ------------------------------------------------------------------------------------------------
void print(string s)
{
This feature is available in Kdevelop and some other text editors that will shrink your blocks of code/comments. It's really quite handy. I often have to use vim to program on the console and this would be very useful to have available.
You don't need a plug-in, the feature is built-in. It's called folding, and folks have examples for folding comment blocks here.
Wow, thanks a lot of the information. I have got the folding working very well. I have just one more question.
Currenty, I can fold anything I have my cursor over and cause all folds to re-open in the document. Is there a way to everything in the document with standard comment patterns and { } fold automatically with a key command?
You can map the folding to an unused key, using the ':map' command. You can, of course, predefine the commands in your vim profile (~/.vimrc and ~/.gvimrc).
Thanks again for the help. Sorry to keep bothering you but I still cannot get the last bit of functionality that I want.
So, thus far I have got vim to fold either fold all comments on startup, but not allow me to manually unfold or fold things individually (though I can toggle on/off for all folds). Here is my current setup if I want to have everything folded automatically:
:set foldmethod=marker
:set foldmarker=/*,*/
:map f v%zf " manually close a fold
:map F zD " manually open a fold
:map <F3> zi " toggle open/close folds
:map <F4> zn " open all folds
Now with these settings, I cannot manually fold individual things but not cause everything in the document to fold on key command. This is what I would like to do...
:set foldmethod=marker
:set foldmarker=/*,*/
:map f v%zf " manually close a fold
:map F zD " manually open a fold
:map <F3> zi " toggle open/close folds
:map <F4> zn " open all folds
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.