Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy paste with line number in Notepad++

Tags:

notepad++

Can you please tell me how can I copy some lines of code in Notepad ++, along with its lines number ?

That is, supposed I have a code.txt opened by notepad ++ like this (numbers are displayed by using Settings --> Preferences --> Editing --> Display line number):

1 This is line 1
2 This is line 2 
.
.
n This is line n

I want to copy it into a .doc / .odt file so that the line number is included in the result, NOT like this:

This is line 1
This is line 2 
    .
    .
This is line n
like image 253
Hoa Nguyen Avatar asked Aug 20 '12 10:08

Hoa Nguyen


2 Answers

You should add line number to your document opened in nodepad++. Then you copied to .doc or other files. To realize this, there may be two ways. For both two ways. Select your lines in nodepad++.

1) Use TextFX->TextFX Tools->Insert line numbers. enter image description here

Instead to this, 2) To remove unnecessary leading zeros

2.1)First Left indent TextFX->TextFX Edit->Indent text sticky left margin enter image description here

2.2)Add numbers Edit->Column Editors in Number to Insert

  • Set Intial Number 1
  • Increase by 1
  • Choose Dec option.

enter image description here I hope this will help.

like image 164
swemon Avatar answered Sep 19 '22 02:09

swemon


This can be done easily without using any addon if you are not strict towards the format of line no. Your file is

1 This is line 1
2 This is line 2 
.
.
n This is line n

go to find, put .* in find what ie regular expression to look everything in a line, then click find all in current document. You will get following in search window.

Line 1: 1 This is line 1
Line 2: 2 This is line 2 
Line 3: .
Line 4: .
Line 5: n This is line n

You can copy the content of search window [right click in the search window -> select all -> copy] and paste in another file. Of course line no is not only number but Line #:. If it is acceptable then your work is done.

like image 44
sincere nice Avatar answered Sep 21 '22 02:09

sincere nice