ascii-blocks.nvim
ascii-blocks.nvim copied to clipboard
support transforming only a given range/visual selection
The current implementation transforms the entire buffer. It would be nice to allow transforming only a particular range, either explicitly provided via :h :command-range
(:-2,+2AsciiBlockify) or by calling with a visual selection (
:'<,'>AsciiBlockify). This will require modifying the
AsciiBlockifycommand at
plugin/ascii_blocks.vim` to accept a range but default to the entire file
- command AsciiBlockify :call ascii_blocks#transform_selection()
+ command -range=% AsciiBlockify :call ascii_blocks#transform_selection()
and/or updating the blockify_current_buf
function in lua/ascii_blocks.lua
to optionally accept start/end row/column arguments, something like
function M.blockify_current_buf(start_row, start_col, end_row, end_col)
start_row, start_col = start_row or 0, start_col or 0
end_row, end_col = end_row or -1, end_col or -1 -- not sure -1 works but you'd want to get the
-- the last row/column in the buffer
-- (snip) --
end
You can get the row/column of the '<
and '>
marks using vim.fn.getpos("'<")
, see this thread.