Sublime Forum

Gobble - emacs' hungry backspace mode for ST2

#1

Hi,

I really liked how emacs handles the backspace key more efficiently and tried to replicate a small bit of functionality in Sublime Text.

The plugin can be found here:
github.com/skyronic/Gobble

This is a video of the plugin in action:
http://www.youtube.com/watch?v=KEQvi09QW1I)

Need feedback and suggestions before I submit it into package control!

0 Likes

#2

wow, this is pretty nice!
Thanks!

I think there are some problems on haml:
screencast.com/t/Kd3PQkoBu
(note how indentation changes when i press backspace)

0 Likes

#3

[quote=ā€œiamntzā€]wow, this is pretty nice!
Thanks!

I think there are some problems on haml:
screencast.com/t/Kd3PQkoBu
(note how indentation changes when i press backspace)[/quote]

Hi!

Thanks for trying it out.

I can reproduce your bug. I think the reason this is happening is because I re-indent the line every time, and rely on sublimeā€™s in-built re-indenting functionality.

Iā€™ll make some more changes now to preserve the same level of indentation.

0 Likes

#4

Looks nice. Iā€™ll give it a go once others find initial bugs :mrgreen: :mrgreen: :mrgreen:

What screen capture software are you using? :smile:

0 Likes

#5

[quote=ā€œwuubā€]Looks nice. Iā€™ll give it a go once others find initial bugs :mrgreen: :mrgreen: :mrgreen:

What screen capture software are you using? :smile:[/quote]

Hi wuub!

Thanks :smiley: ! Do let me know if you find any issues.

Iā€™m using gtk-recordmydesktop (linux) and key-mon code.google.com/p/key-mon/ ]

0 Likes

#6

[quote=ā€œiamntzā€]wow, this is pretty nice!
Thanks!

I think there are some problems on haml:
screencast.com/t/Kd3PQkoBu
(note how indentation changes when i press backspace)[/quote]

Hey iamntz,

I have fixed the bug you encountered. The reason was that I was calling the ā€œreindentā€ command after deleting a line.

Now I just copy the original whitespace string and re-prepend it after it has been deleted. It should work much better for languages which do not have a stable re-indent mechanism and even plain text!

0 Likes

#7

Pretty cool. Thanks!

0 Likes

#8

I like what youā€™re trying to do with Gobble, but I just encountered a point of contention regarding auto indent.

Consider creating a new function in Ruby:

def new_function

end

I donā€™t use a lot of snippets, so when I do this, I type ā€˜def new_functionā€™ and then ENTER, and with auto indenting, the insertion point would be on the next line but indented one more level:

def new_function<enter>
     |<insertion point>

My normal practice is to then press ENTER again to go to the next line, BACKSPACE to back up one indentation level and type ā€˜endā€™. But with Gobble, I canā€™t. When I press BACKSPACE, I go back to the previous line. So I either need to not use auto indent (unlikely) or SHIFT+TAB instead of BACKSPACE before typing ā€˜endā€™. Iā€™m not sure which is better. Iā€™ll have to play with it a bit and see what I think.

[Or I could just start using a snippet and save myself from typing ā€˜endā€™ a lot! :smile:]

Either way, thanks for making the Sublime Community a little better!

0 Likes

#9

@phillip.koebbe: at least on windows, shift+backspace works pretty much as expected :smile:

Edit:

Thanks! Works awesome!

0 Likes

#10

Wow. Thanks for that! And on a Mac, SHIFT+BACKSPACE works pretty much as expected, too HAH HAH.

You know, in all my years of pecking on a keyboard, I canā€™t think of a time that Iā€™ve shifted a backspace. Har har.

In related news, I think Iā€™ve decided to use a snippet. Thereā€™s already one for ruby and I just need to change it a little to my liking.

0 Likes

#11

Not so awesome in Python. Since python is an indention language, it is frustrating when you get auto-indented but you want to back out because the code block is done, and then gobble wonā€™t let you backspace proper.

0 Likes

#12

Thatā€™s what I was referring to. Youā€™re left with the choices of shift+tab or shift+backspace, neither of which is particularly appealing. If you have a keyboard with assignable keys, you can reduce it to one keystroke, so then itā€™s just a matter of retraining the muscle memory from backspace to the new location.

Iā€™m going to run with it a couple of days and see what happens. I never know until I try ā€¦

0 Likes

#13

Yeah, I normally donā€™t write python. But I noticed the same issue while I was writing the plugin source code itself.

Do you think itā€™s better if I alias it to some other keybinding (ctrl+backspace) perhaps. This would fall back to the default binding of ctrl+backspace (backward delete word) if itā€™s not the first character of a line - and it performs the gobble operation if it is.

0 Likes

#14

[quote=ā€œphillip.koebbeā€]I like what youā€™re trying to do with Gobble, but I just encountered a point of contention regarding auto indent.

Consider creating a new function in Ruby:

def new_function

end

I donā€™t use a lot of snippets, so when I do this, I type ā€˜def new_functionā€™ and then ENTER, and with auto indenting, the insertion point would be on the next line but indented one more level:

def new_function<enter>
     |<insertion point>

My normal practice is to then press ENTER again to go to the next line, BACKSPACE to back up one indentation level and type ā€˜endā€™. But with Gobble, I canā€™t. When I press BACKSPACE, I go back to the previous line. So I either need to not use auto indent (unlikely) or SHIFT+TAB instead of BACKSPACE before typing ā€˜endā€™. Iā€™m not sure which is better. Iā€™ll have to play with it a bit and see what I think.

[Or I could just start using a snippet and save myself from typing ā€˜endā€™ a lot! :smile:]

Either way, thanks for making the Sublime Community a little better![/quote]

Hi Phillip, facelessuser,

I figured out a fix for this - a way you can use Gobble and still work easily using your older muscle memory.

If you press backspace on an empty line (say after finishing a function block and wanting to type ā€˜endā€™) - it will only go back one level of indentation!!

Do try it out and let me know how it works!

0 Likes

#15

[quote=ā€œskyronicā€]

Hi Phillip, facelessuser,

I figured out a fix for this - a way you can use Gobble and still work easily using your older muscle memory.

If you press backspace on an empty line (say after finishing a function block and wanting to type ā€˜endā€™) - it will only go back one level of indentation!!

Do try it out and let me know how it works![/quote]

I just gave it a quick whirl and it looks promising! Iā€™ll have it running today and let you know how it goes. Thanks for work!

0 Likes

#16

This looks pretty sweet! Are you planning on adding it to package control eventually?

0 Likes