• $ cat "

    Emacs Excercies Revisited: Bulleted List to Numbered List

    "

    In a previous post I presented the following problem and solved it using a regex with an embedded elisp expression.

    * Foo
    * Foo
    * Foo
    * Foo
    * Foo
    * Foo
    * Foo
    * Foo

    That list should be transformed into a numbered (one based) list, like so:

    1. Foo
    2. Foo
    3. Foo
    4. Foo
    5. Foo
    6. Foo
    7. Foo
    8. Foo

    It's time to revisit that problem, and present an alternative solution.

    For this simple problem a regex is a bit of an overkill. This could easily be solved with a keyboard macro.

    Solution using a keyboard macro:

    - Set the macro counter to 1 (C-x C-k C-c 1)
    - Start recording a macro (F3)
    - Insert the macro counter followed by ". " at the beginning of ther first line (F3)
    - Move to the next line and finish the macro (F4)
    - Run the macro to the end of the file (C-u 0 C-x e)