Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to work out how to get code folding working how I want in Sublime Text 2.

I can +K, +J to unfold all. Then I can do +K, +1 to fold all.

At this point, I want to be able to go straight to fold level x (i.e. fold level 2). But if I do +K, +2, nothing happens.

To get to fold level 2, I first have to unfold all, then do +K, +2.

How can I specify the fold level, with keyboard shortcuts, without having to unfold all first?

share|improve this question
    
This guide should be helpful for you. –  Anton Dozortsev Apr 13 at 8:37

1 Answer 1

In your sublime text keymap, add:

{ "keys": ["ctrl+1"], "command": "fold_by_level", "args": {"level": 1} },
{ "keys": ["ctrl+2"], "command": "fold_by_level", "args": {"level": 2} },
{ "keys": ["ctrl+3"], "command": "fold_by_level", "args": {"level": 3} },
{ "keys": ["ctrl+4"], "command": "fold_by_level", "args": {"level": 4} },
{ "keys": ["ctrl+5"], "command": "fold_by_level", "args": {"level": 5} },
{ "keys": ["ctrl+6"], "command": "fold_by_level", "args": {"level": 6} },
{ "keys": ["ctrl+7"], "command": "fold_by_level", "args": {"level": 7} },
{ "keys": ["ctrl+8"], "command": "fold_by_level", "args": {"level": 8} },
{ "keys": ["ctrl+9"], "command": "fold_by_level", "args": {"level": 9} },

Level 1 is fold all. Match the "," in your JSON to work. Done. ;)

share|improve this answer

Your Answer

 
discard

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.