How to generate a number sequence in file using vi or Vim?

前端 未结 10 2042
野趣味
野趣味 2020-12-07 09:47

Is there a way to generate a number sequence in vi or Vim?

For example, for an arbitrary range of lines i  through j (where i < j

10条回答
  •  伪装坚强ぢ
    2020-12-07 10:29

    A less flexible, but an easy to remember method is to use a renumbering plugin like Renumber.vim http://www.vim.org/scripts/script.php?script_id=189

    If there aren't any numbers yet, like in the OP, some number should be inserted in their place. Renumber can handle the actual ordering and it does it based on just the first number.

    In this example I'm using to insert the starting number on all the lines you want numbered.

    4G4jGI1 gv:Renumber

    To use steps of two

    :Renumber s2

提交回复
热议问题