Sublime Forum

Block Nav: Like CTRL+M for braceless langs like Ruby, Python

#1

I couldn’t find something before, so I created a plugin to assist with navigating block structures in “braceless” languages like Ruby and Python via key binding. E.g.

[code]def
end

do
end

begin
[rescue]
end

if
[elsif]
[else]
end[/code]

The plugin allows jumping from something like do to end and vice versa via key combo. Or jumping out to the start of a block (e.g. def | if | elsif | else) from a line inside the block.

It relies on code being well indented and not mixing tabs and spaces. It’s a bit rough, but functioning.

0 Likes

#2

Ooft! If I can modify this to work with PHP (the language I use daily) this will be handy for me.

0 Likes

#3

If your code is well indented then you should be able to use it as-is if you want to be able to jump out of the middle of a block to find the beginning in PHP. But that’s all it would really add, since in PHP you have curly braces around blocks that you can do bracket matching on to move between the start and end. This plugin is an attempt to compenstate for the absence of those braces around blocks in languages like Ruby and Python and allow you to do something like the bracket matching that’s already possible with PHP.

0 Likes