How to insert a column of increasing numbers in Sublime Text 2?
The Text Pastry plugin does the job very well. It offers the Insert Numbers Syntax.
Select multiple lines with CMD+SHIFT+L (Sublime default):
text|
text|
text|
text|
Move the cursor where you want it:
| text
| text
| text
| text
And insert numbers with Text Pastry by hitting CMD+ALT+N and entering 1 space 1 space 0:
1| text
2| text
3| text
4| text
Where 1 space 1 space 0 stands for:
- Integer to start with 1
- Increment by 1
- Padd leading zeros 0
Replace CMD with CTRL on Windows or Linux machines.
For this particular case you can use Increment Selection package. Just press Ctrl+Alt+I (Command+Control+I) while having multiple cursors at the beginning of each line. In addition to melinath answer, here's an example of how to do it:
You will need Package Control first. It shouldn't take more than 30 seconds to install both things.
Steps:
- Install Package Control.
- Open Command Palette: Ctrl+Shift+P (Mac: Command+Shift+P).
- Type
Install Package Control
and click to install.
- Install Increment Selection package.
- Open Command Palette again.
- Type
Package Control: Install Package
, click on it and wait a short period. - Type
Increment Selection
and click on it to install.
- Add line numbers to the beginning of each line.
- Select all lines with Ctrl+A (Mac: Command+A)
- Change selection to multiple lines with Ctrl+Shift+L (Mac: Command+Shift+L)
- Go to the start of each line by pressing Home (Mac: Command+←)
- Use Increment Selection with Ctrl+Alt+I (Mac: Command+Control+I)
Result:
Other examples for Increment Selection
Increment Selection can also replace numbers, prefix numbers with leading zeroes, increment letters, increment by a step and more.
[1] text [1] text [1] -> 1| text 2| text 3|
[a] text [a] text [a] -> a| text b| text c|
[01] text [01] text [01] -> 01| text 02| text 03|
[05,3] text [05,3] text [05,3] -> 05| text 08| text 11|
[5,-1] text [5,-1] text [5,-1] -> 5| text 4| text 3|
Hint: []
stands for a selection, |
stands for a caret.
Featured similar plugins
- Selection Evaluator: Evaluate selected mathematical expression with Ctrl+Shift+M (Mac: Command+Shift+M).
copy of this post https://stackoverflow.com/a/64083371/5902698
You want to had a number at each row that you have selected, but not the same. For exemple, you select 5 cursors and you want to write 1 2 3 4 5.
select your 5 cursors (maybe you can use the shortcut ctrl + shift + L)
ctrl + maj + P and select arithmetic
Because you have 5 cursors, it propose 1 2 3 4 5
If you want you can change your step of iteration
Or start from an other number than 1
Add even numbers
The IncrementSelection plugin enables this behavior. If you have Package Control installed, you can just search for and install it. Easy peasy!
Use Emmet package try this :
{$ text${newline}}*4