Skip to main content
added 2 characters in body
Source Link
jjaderberg
  • 3.6k
  • 1
  • 14
  • 20

You could do this by

  1. recording a macro, then
  2. using the global ex command to execute the macro n number of times for each line in the file.

After recording the macro, undo the changes done while recording, or there will be 13n + 1 additional lines for the first line, and twelven for consecutive lines.

Record the macro to the a register with

qayyp$?\d<CR><C-A>q

This records into register a (qa...q) the following command:

  • yyp: duplicate the current line
  • $: move to end of line
  • ?\d<CR>: search backwards for a single digit
  • <C-A>: increment digit under the cursor by one

When the macro is recorded, remove the changes made while recording it either by undoing (uu) or by deleting the current line (dd). Then repeat the macro 1211 (or any number of) times for each line in the file with the global command:

:g//normal 12@a11@a

You could do this by

  1. recording a macro, then
  2. using the global ex command to execute the macro n number of times for each line in the file.

After recording the macro, undo the changes done while recording, or there will be 13 additional lines for the first line, and twelve for consecutive lines.

Record the macro to the a register with

qayyp$?\d<CR><C-A>q

This records into register a (qa...q) the following command:

  • yyp: duplicate the current line
  • $: move to end of line
  • ?\d<CR>: search backwards for a single digit
  • <C-A>: increment digit under the cursor by one

When the macro is recorded, remove the changes made while recording it either by undoing (uu) or by deleting the current line (dd). Then repeat the macro 12 (or any number of) times for each line in the file with the global command:

:g//normal 12@a

You could do this by

  1. recording a macro, then
  2. using the global ex command to execute the macro n number of times for each line in the file.

After recording the macro, undo the changes done while recording, or there will be n + 1 additional lines for the first line, and n for consecutive lines.

Record the macro to the a register with

qayyp$?\d<CR><C-A>q

This records into register a (qa...q) the following command:

  • yyp: duplicate the current line
  • $: move to end of line
  • ?\d<CR>: search backwards for a single digit
  • <C-A>: increment digit under the cursor by one

When the macro is recorded, remove the changes made while recording it either by undoing (uu) or by deleting the current line (dd). Then repeat the macro 11 (or any number of) times for each line in the file with the global command:

:g//normal 11@a
Source Link
jjaderberg
  • 3.6k
  • 1
  • 14
  • 20

You could do this by

  1. recording a macro, then
  2. using the global ex command to execute the macro n number of times for each line in the file.

After recording the macro, undo the changes done while recording, or there will be 13 additional lines for the first line, and twelve for consecutive lines.

Record the macro to the a register with

qayyp$?\d<CR><C-A>q

This records into register a (qa...q) the following command:

  • yyp: duplicate the current line
  • $: move to end of line
  • ?\d<CR>: search backwards for a single digit
  • <C-A>: increment digit under the cursor by one

When the macro is recorded, remove the changes made while recording it either by undoing (uu) or by deleting the current line (dd). Then repeat the macro 12 (or any number of) times for each line in the file with the global command:

:g//normal 12@a