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