Skip to content

Instantly share code, notes, and snippets.

@hboon
Last active October 11, 2023 03:56
Show Gist options
  • Save hboon/89674542e2ef2c261d353cbd44707f75 to your computer and use it in GitHub Desktop.
Save hboon/89674542e2ef2c261d353cbd44707f75 to your computer and use it in GitHub Desktop.
Handy Lua function to diff current line and the next
--Modified from https://stackoverflow.com/a/5519588
function diffLineWithNext()
local f1 = vim.fn.tempname()
local f2 = vim.fn.tempname()
vim.api.nvim_command(".w " .. f1)
vim.api.nvim_command("+1 w " .. f2)
vim.api.nvim_command("tabedit " .. f1)
vim.api.nvim_command("hor diffsplit " .. f2)
vim.api.nvim_command("set wrap")
vim.api.nvim_command("wincmd w")
vim.api.nvim_command("set wrap")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment