AllenDang/nvim-expand-expr

github github
editing-supports plugin
star 16
stars
alert-circle 0
open issues
users 1
subscribers
git-branch 0
forks
CREATED

2021-08-13

UPDATED

4 months ago

packer

require('packer').startup(function()
  use 'AllenDang/nvim-expand-expr'
end)

paq

require "paq" { 
  'AllenDang/nvim-expand-expr'
}

nvim-expand-expr

Expand and repeat expression to multiple lines for neovim.

demo.gif!

Requirements

Neovim >= 0.5

Installation

packer.nvim

use 'AllenDang/nvim-expand-expr'

Usage

require("expand_expr").expand()

It will parse cursor line and expand it base on below syntax.

range|expr

range

range has two forms.

  1. 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)
  1. Range format 3,7|print({%d}) will expand to
print(3)
print(4)
print(5)
print(6)
print(7)

expr

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