Skip to main content

Numbering lines

The rectangle-number-lines command in emacs is very handy for adding a series of numbers to a file.

  1. Mark the rectangular that you want to number.
  2. Invoke the rectangle-number-lines command with C-x r N.

The command will prompt for a starting number and a format, if invoked with a prefix argument (i.e. C-u).

Example

Before:

('a', ),
('b', ),
('c', ),
('d', ),

After (with a start value of 97 and format of "3d, "):

( 97, 'a'),
( 98, 'b'),
( 99, 'c'),
(100, 'd'),