I am NOT looking for emacs's line-number mode. I don't want to just display line numbers. I want to insert line numbers in a buffer, starting at point
and going to mark
, or perhaps continuing for some number that I specify via C-u. For example, suppose I have the following lines in my buffer:
So shall I live, supposing thou art true,
Like a deceived husband; so love's face
May still seem love to me, though alter'd new;
Thy looks with me, thy heart in other place:
For there can live no hatred in thine eye,
Therefore in that I cannot know thy change.
In many's looks, the false heart's history
Is writ in moods, and frowns, and wrinkles strange.
But heaven in thy creation did decree
That in thy face sweet love should ever dwell;
Whate'er thy thoughts, or thy heart's workings be,
Thy looks should nothing thence, but sweetness tell.
How like Eve's apple doth thy beauty grow,
If thy sweet virtue answer not thy show!
Now i put the cursor on line 3, the line that begins with the word "May." Then, I type C-u7M-xyour-new-elisp-program
RET; or I type C-space, scrape down to line 9, the line that begins with "But," and then type M-xyour-new-elisp-program
RET. In both cases, I get something like:
So shall I live, supposing thou art true,
Like a deceived husband; so love's face
001 May still seem love to me, though alter'd new;
002 Thy looks with me, thy heart in other place:
003 For there can live no hatred in thine eye,
004 Therefore in that I cannot know thy change.
005 In many's looks, the false heart's history
006 Is writ in moods, and frowns, and wrinkles strange.
007 But heaven in thy creation did decree
That in thy face sweet love should ever dwell;
Whate'er thy thoughts, or thy heart's workings be,
Thy looks should nothing thence, but sweetness tell.
How like Eve's apple doth thy beauty grow,
If thy sweet virtue answer not thy show!
I don't know enough elisp to start this, but I vaguely recall seeing an episode of "emacs rocks" a long time ago with an insanely short snippet of code done on-the-fly to do it! I haven't been able to find the episode again.
Every other "Similar Question" suggested seems to pertain to emacs's line-number mode, which apparently doesn't help me.
EDIT: I know that multiple-cursors may have a command to do this, but multiple-cursors seems to be permanently broken in Spacemacs, and I must use Spacemacs so that I can evangelize VIM users.
C-x C-k C-f %03d RET C-1 <f3> <f3> SPC C-a C-n C-7 <f4>
. I'm sure it's a comparable number of keystrokes in evil.