Sublime Forum

nRepeat: repeat anything any amount of times

#1

The nRepeat plugin ports the repeat functionality of the universal-argument from Emacs to SublimeText3.

You can check it out, along with a short introduction, at:

github.com/bfrascher/Sublime-nRepeat

EDIT It is now available directly from the Package Control!

About a year ago I tried making this plugin in SublimeText2, but I wasn’t satisfied with the result. So now I tried again with some new API calls from SublimeText3 and while I am also not completely satisfied with the current result, it is a start one can build on. The main problem is still catching single character inputs from the user, as I have not found anything related to that in the new API documentation. I solve this issue in the current release by reading the last inserted character in the active view, saving it in the plugin and finally deleting it from the view again. This works quite well (even with multiple selection regions), except when there is selected text. That text will always be overwritten by the user input and I have yet to find a nice way of preventing this, while also reading in the characters.

Anyways, if you decide to try out the plugin, have fun, but be aware that you might have to rely on your ‘undo’ key a lot more :wink:
And if you have any suggestion on improving it, or a question about it, feel free to leave me a comment or send me a message.

Thanks
Benedikt

PS
The title says ‘repeat anything’, but really at the time you can only repeat single characters and text commands. Window commands are currently not supported. Also I have implemented a maximum number of times anything will be repeated, as to stop SublimeText from becoming unresponsive. At the time the limit is at 1000000 repeats. If you feel this is too restrictive, let me know or fork the plugin for yourself :wink:

1 Like

#2

I just released version 0.1.2 of the plugin, in which I fixed the problems with selected text.
When a selection is active, characters are now inserted right in front of, or right behind of the selection, depending on where your text cursor is. Commands are simply executed on the region itself. This works with multiple selection regions.

1 Like