@OdatNurd: Great, your code does just what I was looking for. Really appreciate your help, thank you.[quote=“OdatNurd, post:6, topic:30177, full:true”]
There are undoubtedly many packages available that could be made to do what you want to do, although if you’re new to Sublime that might seem a little overwhelming. As has been mentioned, a better idea of what you’re ultimately trying to accomplish may make it easier for someone to come up with something more concrete that’s not too heavy-weight.
By way of a simple example that inserts a sequence of numbers into the current file, there is this:
import sublime
import sublime_plugin
class InsertNumbersCommand(sublime_plugin.TextCommand):
def input(self, first, second):
if second is None:
return self.view.window().show_input_panel("To", "50",
lambda val: self.input(first, val), None, None)
for x in range(int(first), int(second) + 1):
self.view.run_command("insert", {"characters": "%d\n" % x})
def run(self, edit):
self.view.window().show_input_panel("From", "1",
lambda val: self.input(val, None), None, None)
This implements a simple command named insert_numbers
which will prompt you (in an input box near the bottom of the window) for a number to start from and a number to go to, and will then insert that sequence of numbers into the current file one after the other on their own lines.
It’s simple so it doesn’t do error checking like making sure that you enter actual numbers, for example. It uses the insert
command to insert the numbers, so if you have multiple selections it will insert the sequence at all of them. overwrite the current selection with the sequence, etc.
To play with it you can select Tools > Developer > New Plugin...
from the menu, then replace the contents of the template plugin with this text and save it in the location that Sublime defaults to (your User
package). From there you can bind insert_numbers
to a key to actually run it.
[/quote]