문제

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