How to input ordered number in multi line mode?


when in multi line mode
i want to get this result:


how could i get this?


There isn’t a built-in way to do that. You could add this to your to create a command that would do it:

atom.commands.add 'atom-workspace',
  'custom:insert-numbers': ->
    editor = atom.workspace.getActiveTextEditor()
    count = 0
    for selection in editor.getSelections()
      count += 1

You could create a keybinding for this using the normal methods once you restart Atom. You do have to be careful to create the multiple cursors in the correct order because it inserts the numbers in the order of the selections.


I made some modifications to the script above to squeeze a bit more functionality out:

atom.commands.add 'atom-workspace',
	'custom:insert-numbers': ->
		editor = atom.workspace.getActiveTextEditor()
		selections = editor.getSelections()
		[num, incBy, radix] = selections[0].getText().split(" ")
		if not num? or num == ""
			num = 0
		if not incBy? or incBy == ""
			incBy = 1
		if not radix? or radix == ""
			radix = 10

		num = parseInt(num)
		incBy = parseInt(incBy)
		radix = parseInt(radix)

		for selection in selections
			numText = num.toString(radix)
			num += incBy

Highlight the arguments with the first cursor to optionally change the starting number, the quantity by which it is incremented, and the output radix. Separate the arguments with a space

Hope this helps someone!

How to add image file to the project?