Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of GVim folding comments in your code?

Tags:

c

vim

vi

There is someone in my team that swears by using some kind of GVim feature to do manually code folding.

As I'm using another editor and do not really need the folding feature, I think it only pollutes the source code with tags like:

/* {{{1 */

Convincing the person not to use this folding is not an option (got into some heated discussions before).

I'm not really a GVim guy, I'm wondering if there are not any other ways to do the folding without changing the team's code?

  • Maybe putting the folding directions in a separate file, or
  • Doing some kind of smart folding that takes the syntax of the programming language into account without changing the source code?
like image 415
Roalt Avatar asked Dec 18 '08 19:12

Roalt


2 Answers

I would imagine he could just add the following to his .vimrc:

set foldmethod=syntax

Assuming he is using a version of VIM that supports that. :)

like image 56
grieve Avatar answered Nov 15 '22 00:11

grieve


It only took a Google for "vim folding" to discover that Vim supports six fold methods.

syntax, indent and diff all mean that the user has little control over where the folding happens. That may or may not be a problem.

marker is a problem for you because you don't like the markers.

expr had a little of each of those problems, depending on the expression you create.

If your man wants to define his own fold points, and store them in an separate file, it seems like set foldmethod=manual combined with :mkview and :loadview would do the trick.

like image 25
slim Avatar answered Nov 15 '22 01:11

slim