Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save text folds and folded code block data to .sublime-workspace?

Seems like there are no features in Sublime Text 2 that keep code folding between file sessions close\open.

I'd like to write plugin for this, but have a question.

Where should I store fold-data such as which file, or region on the page is folded? My Only idea saves in .sublime-workspace

So, how I can access it and read my properties, attributes, or what meta-data not?

Where else can I store data such as what is required to persist fold regions?

like image 283
gridsane Avatar asked Jul 06 '12 20:07

gridsane


People also ask

How to collapse Sublime?

Press Ctrl. Press K (without releasing Ctrl )


2 Answers

First of all, There's already a really nice plugin that does that and much more, it's called BufferScroll

Buffer Scroll is a simple Sublime Text plug-in which remembers and restores the scroll, cursor positions, also the selections, marks, bookmarks, foldings, selected syntax and optionally the color scheme.

Trying to answer your question, I did a quick check on BufferScroll source code and it seems that it store all data in Settings folder inside a Gzip file. on mac it's at ~/Library/Application Support/Sublime Text 2/Settings/BufferScroll.bin.gz it's worth to mention that it's the same folder sublime text uses to store session, auto-save session and license files.

like image 120
Allen Bargi Avatar answered Nov 07 '22 20:11

Allen Bargi


update sep 2017, using sublime 3, to make fold persistence after we close document, there is autofoldcode in package control, I just installed and it's working as expected.

like image 45
widjajayd Avatar answered Nov 07 '22 21:11

widjajayd