Complete the sequence 1 2 3 up to 156 in Notepad++?

11

6

I have a fairly simple request, but I can't figure out how to do this in Notepad++. I need to create a list where each line begins with a number, starting from 1 and ending at 156. Obviously I dont' want to sit and type this in manually, as I will be creating more than one list.

1
2
3
.
.
.
.
156

How do I do that? I tried the macro function but it only plays back keyboard actions. It does not increment the sequence by 1 as Excel would do with its auto-fill feature. I know Excel can do it, but I must avoid using Excel.

a

As you can see I don't have any columns, or any lines of code. I am starting off from an empty document. I just want to create a long list in a text file.

Samir

Posted 2014-02-17T10:41:52.327

Reputation: 17 919

I had a look at "TextFX / TextFX Tools / Insert Line Numbers" and "Edit -> Column Editor" as discussed here. But that's not working for this type of situation. My situation is too simple. :)

– Samir – 2014-02-17T10:50:05.883

Answers

20

In Notepad++ you can press Alt+C for the column / multi-selection editor and use the number to insert function from initial number increasing by 1, you'll just need to select all of your lines that you want to number.

You'll need to have blank lines already. I had to select the lines from the bottom up to the top before running the column editor, but I'm not sure if that's required.

essentially sourced from StackOverflow

Raystafarian

Posted 2014-02-17T10:41:52.327

Reputation: 20 384

You may select a column (or a space for a column, 0 chars width) keeping ALT pressed while selecting with mouse. Then Notepad++ is selecting a box instead of lines. – huhu78 – 2017-09-16T06:18:43.463

I'm not sure you understood the situation. That's just it. It's a "column editor". I don't have any columns, or any lines of code. I am starting off from an empty document. I just want to create a long list in a text file. And if at all possible, I want to cheat using Notepad++ because I don't feel like typing in each number on each new line on and on. – Samir – 2014-02-17T11:32:04.000

You need to have all your lines, highlight from the bottom to the top and then use the column editor. – Raystafarian – 2014-02-17T12:07:18.237

If you can expand your answer to include the bit about inserting new lines we discussed above, I will mark it as a solution. – Samir – 2014-02-17T12:43:27.887

I added in what I mentioned – Raystafarian – 2014-02-17T14:01:59.390

As promised, I have marked your answer as the solution. Cheers! – Samir – 2014-02-17T14:12:39.973

5

Answer provided by Raystafarian is essentially correct.

Please open a new document. Record a macro with only 'Carriage return'. Now play the macro 155 times. So you have 156 lines. Now follow the procedure suggested by Raystafarian.

Wishwas

Posted 2014-02-17T10:41:52.327

Reputation: 128

Got it! That's essentially what I did. I just didn't use a macro to create new lines. And I didn't realize at first that I had to have the lines created first, to use the Column Editor. – Samir – 2014-02-17T12:12:25.233

Thanks for the macro tip! It simplifies things a bit more. Just a small note, after recording the macro, you have to go back to the beginning of the first line. Then you play the macro 155 times. – Samir – 2014-02-17T12:14:41.323

No, you don't have to go to the beginning of the first line. While recording the macro you have already created the first line. Now play the macro 155 times ( Option Run a macro multiple times ) to get the 156 ( 1 + 155 ) lines. Now ctrl + Home will get you to the beginning. – Wishwas – 2014-02-17T12:22:11.453

I don't think so. While on line 1, you start recording, press Enter, and you are on line 2. You stop recording. You go to "Run a macro multiple times" and play it 155 times. Your last line is 157. Because 2+155=157. So you have to either go back 1 line, or play the macro 154 times instead. – Samir – 2014-02-17T12:30:14.103

OK, so I made the usual off-by-one error. – Wishwas – 2014-02-17T13:46:53.140

1

This isn't the solution you asked for, but solves your problem easily: Just open excel or google sheets and enter 1 and 2 in the first two cells. Then click and drag the bottom-right corner down to auto-increment the list.

enter image description here

Then just cut and paste it into your text file.

enter image description here

matt burns

Posted 2014-02-17T10:41:52.327

Reputation: 746

0

Old question but here is an alternative answer (not using notepad++) for anyone looking for the same result.

In command prompt:

FOR /L %A IN (1,1,156) DO ECHO %A >> outputfile.txt

This will start at 1, increment by 1, end at 156. It will append each number as output to outputfile.txt

sample of outputfile.txt:

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 

Rhino

Posted 2014-02-17T10:41:52.327

Reputation: 3

0

Bingo! I have found a way to do it using the Column Editor.

  1. Ctrl+N to create a new empty document.
  2. Go to Settings menu, Preferences, Editing, and make sure "display line number" option is enabled. Click Close.
  3. Press and hold Enter until you have reached line number 156.
  4. Ctrl+Shift+Home to select all the lines (i.e. "columns") from the bottom most to the one on the top. It is necessary to start from the bottom and go up with the selection, so that the text input cursor sits at the beginning of first line whilst everything else is selected down below.
  5. Alt+C to open the "Column / Multi-Selection Editor".
  6. Select "Number to Insert", type in 1 in "Initial number" and 1 in "Increase by". Select "Dec" for decimal numbers, and click OK.

Samir

Posted 2014-02-17T10:41:52.327

Reputation: 17 919

Upvoted because this is the most complete answer here, and the other answers were confusing (incomplete). However, @slhck is right, as per SuperUser guidelines, it is best practice to update your original question, such as "UPDATE: (12/27/16)", then brief description of the update, followed by a line or some separator, then "ORIGINAL POST:", followed by the original post. This method will make help to organize your newly edited question so that it is more understandable. – Eric Hepperle - CodeSlayer2010 – 2016-12-27T17:49:28.547

I've removed the rather pointless comments here. The thing is – if someone answers your question, it's common for the OP to amend the answer to include some additional steps if necessary. Posting another answer is fine, but often quite redundant since other posts can (and should) be edited to be improved. – slhck – 2014-02-17T18:41:45.900

-1

Just do it like a real super user...

perl -e "open(my $fh, '>output.log'); print $fh ($_) for(1..156); close $fh;"

Eric Fossum

Posted 2014-02-17T10:41:52.327

Reputation: 541

2Can you turn this into a teachable moment for those who aren't yet super users? Add a couple of sentences that explain how this works. Thanks. – fixer1234 – 2015-12-08T21:09:22.437

3While this may answer the question, it would be a better answer if you could provide some explanation why it does so. – DavidPostill – 2015-12-09T00:35:27.893