Home Download Buy Blog Forum Support

Gobble - emacs' hungry backspace mode for ST2

Gobble - emacs' hungry backspace mode for ST2

Postby skyronic on Mon Mar 19, 2012 10:49 am

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:
https://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!
Last edited by skyronic on Mon Mar 19, 2012 6:38 pm, edited 1 time in total.
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: Gobble - my first sublime text plugin

Postby iamntz on Mon Mar 19, 2012 12:20 pm

wow, this is pretty nice!
Thanks!

I think there are some problems on haml:
http://screencast.com/t/Kd3PQkoBu
(note how indentation changes when i press backspace)
iamntz
 
Posts: 819
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Gobble - my first sublime text plugin

Postby skyronic on Mon Mar 19, 2012 12:41 pm

iamntz wrote:wow, this is pretty nice!
Thanks!

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



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.
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: Gobble - my first sublime text plugin

Postby wuub on Mon Mar 19, 2012 12:47 pm

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

What screen capture software are you using? :)
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: Gobble - my first sublime text plugin

Postby skyronic on Mon Mar 19, 2012 12:51 pm

wuub wrote:Looks nice. I'll give it a go once others find initial bugs :mrgreen: :mrgreen: :mrgreen:

What screen capture software are you using? :)


Hi wuub!

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

I'm using gtk-recordmydesktop (linux) and key-mon [ http://code.google.com/p/key-mon/ ]
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: Gobble - my first sublime text plugin

Postby skyronic on Mon Mar 19, 2012 5:29 pm

iamntz wrote:wow, this is pretty nice!
Thanks!

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


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!
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: Gobble - my first sublime text plugin

Postby facelessuser on Mon Mar 19, 2012 6:29 pm

Pretty cool. Thanks!
facelessuser
 
Posts: 1457
Joined: Tue Apr 05, 2011 7:38 pm

Re: Gobble - emacs' hungry backspace mode for ST2

Postby phillip.koebbe on Mon Mar 19, 2012 7:12 pm

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:

Code: Select all
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:

Code: Select all
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! :)]

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

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Gobble - emacs' hungry backspace mode for ST2

Postby iamntz on Mon Mar 19, 2012 7:32 pm

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

Edit:
I have fixed the bug you encountered. The reason was that I was calling the "reindent" command after deleting a line.

Thanks! Works awesome!
Last edited by iamntz on Tue Mar 20, 2012 5:06 am, edited 1 time in total.
iamntz
 
Posts: 819
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Gobble - emacs' hungry backspace mode for ST2

Postby phillip.koebbe on Mon Mar 19, 2012 7:54 pm

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


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.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 12 guests

cron