Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Append Text To The End Of A Neovim File Buffer With Lua

The neovim lua function ` nvim _ buf _ set _ lines() [TODO: Code shorthand span ] can be used to append lines to the end of a file buffer like this :

lua
local bufnr = 25
local start_line = -1
local end_line = -1
local strict_bounds = false
local lines = { "alfa bravo", "charlie delta" }

vim.api.nvim_buf_set_lines(
  bufnr, start_line, end_line, strict_bounds, lines
)

That will append one line with "alfa bravo" and another with "charlie delta" to the end of the buffer with id number of 25.

Details