Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/niuiic/part-edit.nvim

Edit a part of a file individually
https://github.com/niuiic/part-edit.nvim

Last synced: about 2 months ago
JSON representation

Edit a part of a file individually

Lists

README

        

# part-edit.nvim

Edit a part of a file individually.

## Usage

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.

1. select code in virtual mode (only support "v" mode)
2. use `PartEdit` to create new buffer
3. save new buffer and the original file will also be updated.

## Dependencies

- [niuiic/core.nvim](https://github.com/niuiic/core.nvim)

## Config

```lua
-- 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,
}
```

```lua
-- keymap example
vim.keymap.set("v", "p", "PartEdit", { silent = true, mode = "v"})
```