Вопрос

I want to insert a sequence of numbers but I need to repeat every number in n lines, I mean:

Original file       New file
1                   1,1
2                   1,2
3                   1,3
4                   2,4
5                   2,5
6                   2,6
7                   3,7
8                   3,8
9                   3,9
Это было полезно?

Решение

You can use a :help sub-replace-expr. A simple .* will match the number, and you can then concatenate the result, using submatch(0) to work with the match:

:%s#.*#\=(submatch(0)+2)/3 . ',' . submatch(0)#
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top