emacs: Orgmode, how to make a list from a block of lines

前端 未结 4 1738
盖世英雄少女心
盖世英雄少女心 2021-02-01 07:02

Is there a way to covert such block of lines

line1  
line2 
linen

into

1. line1
2. line2
n. linen

Using Emac

4条回答
  •  臣服心动
    2021-02-01 07:12

    Found this on emacsworld.blogspot.com (I made some minor edits):

    In Emacs 24.1, the NEWS file had this new addition to the rectangle commands.

    ** New command `C-x r N' (`rectangle-number-lines') numbers the lines in the current rectangle. With a prefix argument, this prompts for a number to count from and for a format string.

    This allows you to now number lines or lists easily without using a macro or additional elisp functions. Mark a vertical region of text (using transient mark mode may help), 1 character wide, and then hit C-x r N and that's it. Emacs numbers the lines.

    If you use the prefix command C-u (for example, C-u C-x r N), it will prompt you for a starting digit and the format string, so you can start at an arbitrary number and specify a period or paren or whatever to precede or follow the number.

提交回复
热议问题