Pergunta

How can I export vim folds from a file, so that I can transfer it to a different machine?

For example say I create the folds in a file and save it on a local machine - where does the "folding" metadata go? Can I just copy it to another machine, or must I manually recreate the folds again?

EDIT: Hm, I've noticed this might be a duplicate question, but still there is not answer as to how to save the fold information WITHOUT modifying the source file.

Thanks

Foi útil?

Solução

Save your session with the :mksession command, and restore it with vim -S Session.vim. The session file will restore almost everything, including folds (though changes to the file will mess it up).

That works if you must use manual folds, but it's really a lot easier to use one of the automatic fold methods — investigate indent, syntax, and expr, and look for syntax files that fully support folding.

Outras dicas

Ok I've figured out a relatively painless way of doing it. This does require some change to the source file however.

First, set the fold-marker to be java style /** comment **/ markers:

:set foldmethod=marker
:set foldmarker=/\*\*,\*\*/

then inside my source any time I want a fold I just type:

/** This is the title of the section */
Some stuff goes here blah
...
//the line below "ends" the fold by double star
/* **/

This produces folds just as I expect them and is much easier to deal with than the "dynamic" or visual folding.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top