Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add command to delete all buffers except "loaded" buffers #9

Open
iamhrigved opened this issue Jul 5, 2024 · 0 comments

Comments

@iamhrigved
Copy link

iamhrigved commented Jul 5, 2024

If suppose I have many splits open and want to delete the useless buffers which are not currently in use (loaded). There must be a command to do this. I think this plugin will be "complete" if this is implemented.

I tried to do something like this

-- save and delete all unloaded buffers
local bufs = vim.api.nvim_list_bufs()
for _, buf in ipairs(bufs) do
    local modifiable = vim.api.nvim_buf_get_option(buf, "modifiable")
    if modifiable then
	vim.cmd("silent w")
    end
    if not vim.api.nvim_buf_is_loaded(buf) then
	vim.api.nvim_buf_delete(buf, { force = true })
    end
end

I don't know why, but it's not working :/

It would be great if you look into this and try to implement this functionality :)

@iamhrigved iamhrigved changed the title Add command to delete all buffers except "loaded" buffers Feature Request: Add command to delete all buffers except "loaded" buffers Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant