Expand and repeat expression to multiple lines for neovim.
Neovim >= 0.5
use 'AllenDang/nvim-expand-expr'
require("expand_expr").expand()
It will parse cursor line and expand it base on below syntax.
range|expr
range
has two forms.
- Single number
10|print({%d})
will expand to
print(1)
print(2)
print(3)
print(4)
print(5)
print(6)
print(7)
print(8)
print(9)
print(10)
- Range format
3,7|print({%d})
will expand to
print(3)
print(4)
print(5)
print(6)
print(7)
expr is a string contains multiple {%d}
parts, the content inside {} will be eval as lua expression.
3|{%d} + {%d+1} + {%d+2}
will expand to
1 + 2 + 3
2 + 3 + 4
3 + 4 + 5
3|{%d .. ' hello world ' .. %d*3}
will expand to
1 hello world 3
2 hello world 6
3 hello world 9