Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have started to use set foldmethod=marker, because I find it more convenient to use rather than syntax.

But it has the disadvantage of needing to write // {{{ my title and // }}} around any folding code candidate.

It would be nice if I could select a part of code in visual mode, and call a command ( or some commands) that would insert the two markers before and after the selected code.

Are there any way to do that in vim ?

share|improve this question
up vote 1 down vote accepted

I found it. Visually select the block then input the command :fold

It automatically writes the two tags /*{{{*/ and /*}}}*/.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.