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 ?

2 Answers 2


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

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


When in visual mode, with the text to be folded highlighted, press zf. This is better than using :fold as you don't have to escape to the command prompt (and use less keystrokes).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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