Sublime Forum

Dev Build 2115

#1

These keyboard shortcuts break convention with naving between tabs on Mac OS X:

  • Fold command is now bound to Command+Shift+ on OS X, and Ctrl+Shift+ on Windows and Linux
  • Unfold command is bound to Command+Shift+] on OS X, and Ctrl+Shift+] on Windows and Linux

Maybe Cmd + Shift + > and Cmd + Shift + < is a better shortcut for collapsing code?

0 Likes

#2

I suggest that we use function keys for these kind of actions since they’re going to be intensively used:

On TextMate you use F1 to Open and to Close Folds. You can use Super + Alt + [1…0] to close different levels of indentation. 0 being “Fold all”, and 1 being “fold first level”.

Just leaving this out there since it’s something that works.

Edit: I see that super+alt+[1…X] are used to handle the splitting windows, which is ok. However F1 is a good folding option.

0 Likes

#3

It’s not my week this week, will change for the next build.

0 Likes

#4

Any week that you add code folding is your week :smile:

0 Likes

#5

[quote=“kuroir”]I suggest that we use function keys for these kind of actions since they’re going to be intensively used:

On TextMate you use F1 to Open and to Close Folds. You can use Super + Alt + [1…0] to close different levels of indentation. 0 being “Fold all”, and 1 being “fold first level”.

Just leaving this out there since it’s something that works.

Edit: I see that super+alt+[1…X] are used to handle the splitting windows, which is ok. However F1 is a good folding option.[/quote]

I used to love Notepad++'s code folding whereby you could (like TextMate) fold to given levels of a source file, but its shortcuts were alt+1, alt+2, alt+3 and I think shift+alt+1, etc. for unfold. (Which I know in ST2 are currently select tab and select layout respectively.) All I’d say is try to avoid the F keys if possible, because on some keyboards (e.g., my MacBook Pro) they have dual functions, and I’d hate to be pressing Fn every time I want to do an operation in ST2 I use with relative regularity.

Also, as the code folding idea is taken forward (as I’m sure it will be) it’s be great to have gutter fold markers like most IDEs do. Would be nice to ‘visually’ fold rather than have to make a selection.

Finally, am I doing something wrong for folding? The only folding I can get to work is tag attribute folding with ctrl+k, ctrl+t. The ctrl+shift+ and ctrl_shift_] don’t appear to work for me, but maybe I’m using it incorrectly. Neither placing the caret next to a bracket nor selecting text invokes the function.

0 Likes

#6

I hope that the key F1 is the one that it’s going to be used to Fold/Unfold. If not, I hope there’s a way for users to set it by themselves:

Any ideas on how to do it currently?

0 Likes

#7

[quote=“sublimator”]@kuroir

import sublime_plugin

class ToggleFold(sublime_plugin.TextCommand):
    '{"keys": "f1"], "command": "toggle_fold"}'
    def run(self, edit):
        view = self.view

        if any(not view.fold(sel) for sel in view.sel()):
            map(view.unfold, view.sel())

Change any to all and wrap the generator expression in a list to taste.[/quote]

Thanks, this is going to be really useful! :smile: right now I’m working on a way for TextMate users to switch to ST2 easily and still be able to go back to TextMate whenever they want.

0 Likes