Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Close A Neovim Window With The API

Code

-- doesn't force close
vim.api.nvim_win_close(WINDOW_ID, {})

Code

-- forces close
vim.api.nvim_win_close(WINDOW_ID, { force=true })

Code

-- (get the id with `vim.api.nvim_set_current_win()`
-- Closes the window (like |:close| with a |window-ID|).

nvim_win_close({window}, {force})  


Attributes: 
    not allowed when |textlock| is active

Parameters: 
    {window}  Window handle, or 0 for current window
    {force}   Behave like `:close!` The last window of a
              buffer with unwritten changes can be closed. The
              buffer will become hidden, even if 'hidden' is
              not set.

References