Last active
October 11, 2023 03:56
-
-
Save hboon/89674542e2ef2c261d353cbd44707f75 to your computer and use it in GitHub Desktop.
Handy Lua function to diff current line and the next
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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