Edit a part of a file individually.
This plugin is designed mostly for editing code in markdown file.
For example, if you enable dotls
in markdown file, you will get these errors.
To avoid the errors above, the plugin creates a new buffer for editing selected code.
- select code in virtual mode (only support "v" mode)
- use
PartEdit
to create new buffer - save new buffer and the original file will also be updated.
-- default config
{
-- float | tab
open_in = "tab",
float = {
win = {
-- the ratio of the floating window width to the editor width
width_ratio = 1,
-- the ratio of the floating window height to the editor height
height_ratio = 1,
},
},
-- whether to delete the buffer when leave
-- notice: you have to delete previous buffer before you run 'PartEdit' again
delete_buf_on_leave = false,
-- path to the swap file of the new buffer
swap_path = function()
return ".swap"
end,
-- default file suffix of selected code (for example, markdown code -> md)
-- this plugin will ask you to input file suffix if no default file suffix specified
default_file_suffix = nil,
-- whether to save original file when update
save_original_file = true,
}
-- keymap example
vim.keymap.set("v", "<space>p", "<cmd>PartEdit<CR>", { silent = true, mode = "v"})