Incrementing Variable Padding With Zeros

I'm trying to number lines with padded numbers, as in 001, 002, 003, etc.

Seems like it should be pretty simple, but I have messed around for literally hours and don't seem to be able to get what I want. One of the problems is that sometimes the numbers come out with padding, sometimes none.

I don't want to number every single line, but would like to put a number at the beginning of lines that I pick one at a time as I scroll through reading the document.

For instance, I might have a body of text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Sed lectus
vestibulum mattis ullamcorper velit sed ullamcorper. Mauris commodo quis
imperdiet massa tincidunt nunc pulvinar. Sed adipiscing diam donec
adipiscing tristique risus nec. Convallis convallis tellus id interdum
velit laoreet id donec ultrices. Eget aliquet nibh praesent tristique
magna sit amet purus gravida. Netus et malesuada fames ac turpis egestas
maecenas. Metus aliquam eleifend mi in nulla posuere sollicitudin
aliquam. Viverra orci sagittis eu volutpat odio facilisis mauris. Nunc
consequat interdum varius sit amet mattis vulputate enim. Eu feugiat
pretium nibh ipsum consequat nisl vel. Elementum pulvinar etiam non
quam. Nisl condimentum id venenatis a condimentum vitae sapien
pellentesque. Proin sed libero enim sed. Duis ultricies lacus sed turpis
tincidunt id aliquet. Pellentesque sit amet porttitor eget. Malesuada
Eget velit aliquet sagittis id. Tempor orci eu lobortis elementum nibh
tellus molestie nunc. Porttitor rhoncus dolor purus non enim praesent
elementum facilisis leo. Pharetra pharetra massa massa ultricies mi quis
hendrerit dolor. Mattis pellentesque id nibh tortor id. Dui vivamus arcu
felis bibendum. Mi sit amet mauris commodo. Volutpat ac tincidunt vitae
semper quis lectus nulla. Dignissim enim sit amet venenatis urna cursus
eget nunc scelerisque. Iaculis urna id volutpat lacus laoreet non. Quam

What I want to do is read through the text and decide where I want to break it and then leave a number at each place, like this:

001
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Sed lectus
vestibulum mattis ullamcorper velit sed ullamcorper. Mauris commodo quis
002
imperdiet massa tincidunt nunc pulvinar. Sed adipiscing diam donec
003
adipiscing tristique risus nec. Convallis convallis tellus id interdum
004
velit laoreet id donec ultrices. Eget aliquet nibh praesent tristique
magna sit amet purus gravida. Netus et malesuada fames ac turpis egestas
005
maecenas. Metus aliquam eleifend mi in nulla posuere sollicitudin
aliquam. Viverra orci sagittis eu volutpat odio facilisis mauris. Nunc
consequat interdum varius sit amet mattis vulputate enim. Eu feugiat
pretium nibh ipsum consequat nisl vel. Elementum pulvinar etiam non
006
quam. Nisl condimentum id venenatis a condimentum vitae sapien
pellentesque. Proin sed libero enim sed. Duis ultricies lacus sed turpis
tincidunt id aliquet. Pellentesque sit amet porttitor eget. Malesuada
007
Eget velit aliquet sagittis id. Tempor orci eu lobortis elementum nibh
tellus molestie nunc. Porttitor rhoncus dolor purus non enim praesent
008
elementum facilisis leo. Pharetra pharetra massa massa ultricies mi quis
009
hendrerit dolor. Mattis pellentesque id nibh tortor id. Dui vivamus arcu
felis bibendum. Mi sit amet mauris commodo. Volutpat ac tincidunt vitae
semper quis lectus nulla. Dignissim enim sit amet venenatis urna cursus
eget nunc scelerisque. Iaculis urna id volutpat lacus laoreet non. Quam

Thanks!

I replaced your example text to remove the the Covid stuff - whether you agree with it or not it is not appropriate here. even as example text.

You should use two macros, one that lets you set the initial value of the variable, simply use the Prompt for User Input action to set a variable to an initial value (probably one).

image

Then in your line number inserting macro, you can use the Insert Text by Typing action and the CalculateFormat token to do something like this:

image

1 Like

Sorry! I don't know why I didn't think to use some ipsum lorem text.

I thought it had to be a fairly simple macro, but where in the manual is the %000%? I found %Dec2%, but not %000%.

Try this page:

https://wiki.keyboardmaestro.com/token/CalculateFormat