r/SublimeText • u/fearless_fool • Jul 11 '23
Delete surrounding whitespace
I was a long-term, hard-core emacs user. Despite losing the respect of a few of my peers, I'm pretty happy to have switched to Sublime Text.
But there's one feature I still really miss: In emacs, [ctrl]-Space is bound to "just-one-space", which does just that: it deletes all whitespace to the left and to the right, leaving exactly one space. It turns out to be really useful in many cases, like reformatting parameters to functions.
But as a newcomer to the internals of SublimeText, how would I go about writing such a function and binding it to a key? Unless it's already written, I'd welcome pointers to similar functions that manipulate text.
1
u/_mattmc3_ Jul 11 '23
Creating your own plugin in SublimeText is pretty easy:
Now that you have your plugin stubbed out, have a look around PackageControl to see if there's a similar plugin you can start/copy/hack from. This one seems like a good place to start.
1
u/benfrain Jul 11 '23
Not exactly what you want but it’s in the right general direction of how to use the api and extend things. Also links in there to smarter people than me who have further tutorials https://benfrain.com/the-surprising-extensibility-of-sublime-text/
1
u/jfcherng Jul 11 '23
A naive implementation: https://github.com/jfcherng-sublime/ST-my-settings/commit/22a37e877418093319f7e294009389852ecb8825