Gustav Blomqvist
Gustav Blomqvist

Reputation: 161

Keybind to fold function or class in Sublime?

Is there a keybind to press the little fold arrow that appears before a function or class?

enter image description here

Upvotes: 2

Views: 1822

Answers (3)

Kieran101
Kieran101

Reputation: 699

Similar to @math2001's answer, ctrl+shift+l will fold a class or function

This only works when the cursor is below the indentation you want to fold.

Ie. you want to fold functionB, the cursor must be on a line above or below functionB's braces

functionA() {
    functionB() { //I will fold under A. Don't fold here
        //Fold me
        functionC() { //Fold me
        } //Fold me
    } //Fold me
}

Upvotes: 0

Mathieu Paturel
Mathieu Paturel

Reputation: 4510

I don't think there is. What you can do though is this:

def my_func():
     # put your cursor wherever you want on a line that has this level of indentation (here 1)
    """my doc"""
    print('this is') # you can put it here
    print('some code that is going to') # or here
    print('folded!')
    if nb % 2 == 0:
        print('this is an even number') # but not here!

press ctrl+shift+[. It going to automatically select the indentation (so your function's content), and fold it up.

Upvotes: 2

Matt Greenberg
Matt Greenberg

Reputation: 2330

Goto EDIT > Code Folding. It will show you all the command for Sublime Text.

Upvotes: 2

Related Questions