36

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?

Mike Lyons
  • 1,748
  • 2
  • 20
  • 33
gridsane
  • 519
  • 4
  • 13

2 Answers2

56

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.

Allen Bargi
  • 14,674
  • 9
  • 59
  • 58
  • I've been looking for something that does this forever. Well, six months at least. Worked great, thanks! – Jason May 01 '13 at 15:31
  • 3
    Late to the party, looks like Buffer Scroll is now only available for ST3. I'm still on ST2 for a few reasons. Is there another alternative anybody knows of for ST2? – Joao Mar 13 '14 at 20:15
  • Thanks!! Been waiting my whole life for this!! Buffer Scroll FTW! – Christopher Mar 14 '14 at 19:03
  • 1
    Any alternative for sublime text 2? – vzhen Apr 04 '14 at 05:48
  • @vzhen you can try clone it, and checkout to the last commit with ST2 support. – gridsane Apr 15 '14 at 06:20
  • [See this question for instructions on installing BufferScroll in ST2](http://stackoverflow.com/a/21616903/1569064) – AGS Oct 24 '14 at 18:58
5

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.

widjajayd
  • 6,090
  • 4
  • 30
  • 41