Closed hyphenrf closed 2 years ago
It's not built-in, but it should be possible to get this from a lua plugin using vis.win:selections_iterator()
.
vis:map(vis.modes.VISUAL, ',', function(keys)
local ranges = {}
local contents = {}
for selection in vis.win:selections_iterator() do
table.insert(ranges, selection.range)
table.insert(contents, vis.win.file:content(selection.range))
end
for source = 1, #ranges do
local target = #ranges - source + 1
vis.win.file:delete(ranges[target])
vis.win.file:insert(ranges[target].start, contents[source])
end
vis.win.selections = {}
vis.mode = vis.modes.NORMAL
vis:feedkeys("<vis-redraw>")
end, "reverse selections")
Here's a start. You probably still want to add something to keep the selections after reversing but you'd have to to some index-juggling.
in
visual
mode, the:help
page says that we can use+
and-
to rotate selected elements. Is there a way to reverse them?