Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert a column of increasing numbers in Sublime Text 2?

Tags:

sublimetext2

text text text text 

after the editing, those text becomes to

1 text 2 text 3 text 4 text 

It's easy in Notepad ++ with the Column Editor, but I don't know how to do the same in Sublime Text 2.

like image 636
yulanggong Avatar asked Feb 01 '13 05:02

yulanggong


People also ask

How do I add numbers in Sublime Text?

Just select the text, split the selection ( ctrl+shift+l ), insert and select $ at the start of the line, and evaluate python ( ctrl+shift+x ) to get increasing numbers.


2 Answers

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.

like image 136
Afr Avatar answered Sep 28 '22 14:09

Afr


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)
enter image description here

ctrl + maj + P and select arithmetic enter image description here

Because you have 5 cursors, it propose 1 2 3 4 5
enter image description here enter image description here

If you want you can change your step of iteration
enter image description here

Or start from an other number than 1
enter image description here

Add even numbers
enter image description here

like image 38
Nicoolasens Avatar answered Sep 28 '22 16:09

Nicoolasens