EmEditor (text editor) Forum Index
   Questions and Answers about EmEditor Core
     number the lines
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
user
Posted on: 2/26/2012 2:20 am
Home away from home
Joined: 9/29/2006
From:
Posts: 212
number the lines
hello!

I want to number the lines of a text file, by inserting 1), 2), 3), etc at the begining of each line

how can this be done?

thanks!
webern
Posted on: 2/26/2012 4:03 am
Not too shy to talk
Joined: 11/23/2006
From: Moscow, Russia
Posts: 38
Re: number the lines
You can use Insert Sequence Numbers plug-in (32-bit)

or a .jsee-macro like this one:

var n = document.GetLines();
var a = new Array();
for (var i=1; i<(n+1); i++) a.push(i + ") " + document.GetLine(i));
document.selection.SelectAll();
document.write(a.join("\n"));
Quit();
Stefan
Posted on: 2/26/2012 10:21 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 263
Re: number the lines
a) make an zero-width selection in front of the lines
b) execute "Edit > Advanced > Numbering..."
c) press [OK]
Note: to pad with zeros enter them into the "First Line" field like "01" or "0001"

d) while still have that inserted numbers selected do an regex s&r:
Find: (\d\d)
Replace with: \1)

[X]Use regex
[X]In selection only

Note: the amount of find "\d" patterns depends on how many zeros you have padded.
"\d\d" will match two digits.
"\d\d\d" or "\d{3}" will match three, and so on...
Threaded | Newest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文