Question

Ive started using Aptana 3 today and really like it,

However I'm struggling to find out if I can code fold to specific levels.

For example I can push Ctrl+Shift+Divide and will collapse EVERYTHING imaginable.

Including the class.

lets just say my doc is as follows:

class Kill_model extends Game_Model{

    function shoot(){
       //code
       //code
       //code
       //code
       //code
    }

    function respawn(){
       //code
       //code
       //code
       //code
       //code
    }

    function spectate(){
       //code
       //code
       //code
       //code
       //code
    }

}

The default will collapse to

class Kill_model extends Game_Model{}

I've been using PHPEdit in the past, and like to "Fold to Level 2"

This gives me the appearance of

class Kill_model extends Game_Model{

    function shoot(){}

    function respawn(){}

    function spectate(){}

}

I was wondering if its possible to just fold down to level 2, by level 2 I assume it means 2 levels deep. Level 1 = Class, level 2 = functions within.

Many thanks.

Était-ce utile?

La solution

Ok, so level folding is available in Aptana, it just isn't built into PHP editing, only Source editing. To add it to PHP, you can go to Commands > Source > Edit this Bundle, and the Commands > PHP > Edit this Bundle and copy Source/commands/folding.rb to PHP/commands/folding.rb (this will be a new file). If you do not have Option and Command keys (Mac, I believe), you will want to change the keybindings in this file to something else, like Control and Alt. You will find the keybinding in the folding.rb file looking something like this:

with_defaults :input => :none, :output => :discard, :key_binding => "OPTION+COMMAND+0" do

and a second time like this:

cmd.key_binding = "CONTROL+ALT+" + level.to_s

Just change the OPTION to CONTROL and the COMMAND to ALT, and you will have a new Ctrl+Alt+ shortcut once you restart Aptana.

Autres conseils

See my second answer for more direct info... I thought I'd leave this one in case it helps someone with a similar but not quite the same problem...

I can't speak for the keyboard shortcut because I don't know where numpad_divide is on my laptop (no numpad) - but if you look under Window > Preferences > Aptana Studio > Editors > PHP, you can choose to initially fold "these elements" - if you check "Functions" I think you may get the folding you are looking for. However, I do not think this preference will affect the behavior of Ctrl+Shift+Divide aka Collapse All.

There is also a command to collapse the current block (Ctrl+Numpad_minus) but I think this would be less useful to you.

You may also find the Quick Outline helpful, if you are looking for a short overview of the available classes and functions in your file. This can be accessed with Ctrl+O (or right click > Quick Outline).

Edit: Playing around with Aptana today I found, under Commands > Source > Folding > Toggle Foldings at Level > Level <x>. There appears to be a shortcut associated with each level, Alt+1, Alt+2, etc. but it doesn't work for me. I also don't see an option to configure a shortcut for these commands, but you can theoretically make your own.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top