ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Increment Selection

by yulanggong ALL

Add a number to each selection in Sublime Text, incremented once per selection

Details

  • 2017.09.19.10.21.01
  • github.​com
  • github.​com
  • 4 years ago
  • 53 minutes ago
  • 8 years ago

Installs

  • Total 41K
  • Win 22K
  • Mac 13K
  • Linux 6K
Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2
Windows 9 9 15 8 12 4 6 11 11 10 20 22 4 4 8 6 15 10 16 5 6 9 6 10 8 10 6 5 13 12 16 7 6 5 4 13 10 9 6 12 5 4 14 10 14 12
Mac 3 3 5 6 8 2 4 2 6 7 4 8 0 3 6 7 9 5 5 2 2 7 10 9 6 5 6 2 3 9 3 5 5 2 6 5 3 6 6 4 5 2 5 9 10 6
Linux 1 1 4 2 3 0 0 1 5 2 4 3 0 1 4 1 3 5 3 1 2 0 4 2 4 4 0 2 7 4 7 4 0 2 0 2 2 1 2 4 2 0 2 0 4 6

Readme

Source
raw.​githubusercontent.​com

Increment Selection

Add a number to each selection in Sublime Text, incremented once per selection. You may also insert the number of line containing the selection by using the '#' symbol.

This plugin is based on Riccardo Marotti's answer on StackOverflow. The default hotkey is ctrl alt i or cmd ctrl i.

Usage

Place the cursors where you need:

step 1

Insert the number the counter should start from (in this case 1):

step 2

Select the number you typed (shift <—):

step 3

Type the shortcut:

step 4

Examples

Tips: [] stands for a selection, | stands for a caret.

[1] text [1] text [1] -> 1| text 2| text 3|

[a] text [a] text [a] -> a| text b| text c|

[A] text [A] text [A] -> A| text B| text C|

[01] text [01] text [01] -> 01| text 02| text 03|

[05,2] text [05,2] text [05,2] -> 05| text 07| text 09|

[5,-1] text [5,-1] text [5,-1] -> 5| text 4| text 3|

[a,3] text [a,3] text [a,3] -> a| text d| text g|

Increment follows the difference between the first and second element:

[10] text [9] text [1] -> 10| text 9| text 8|   

[a] text [c] text [a] -> a| text c| text e|

Generate line numbers:

[#] line -> 1| line
[#] line -> 2| line
[#] line -> 3| line
[#] line -> 4| line
[#] line -> 5| line