mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
24 lines
734 B
Lua
24 lines
734 B
Lua
vim.api.nvim_create_user_command("Retab", function(opts)
|
|
if #opts.fargs ~= 2 then
|
|
return print("should have exactly two argument: [src] and [dst]")
|
|
end
|
|
local src = tonumber(opts.fargs[1])
|
|
local dst = tonumber(opts.fargs[2])
|
|
if src == nil then
|
|
print("first argument [src] is not a valid number")
|
|
end
|
|
if dst == nil then
|
|
print("second argument [dst] is not a valid number")
|
|
end
|
|
|
|
vim.bo.shiftwidth = src
|
|
vim.bo.tabstop = src
|
|
vim.bo.expandtab = false
|
|
vim.cmd("%retab!")
|
|
vim.bo.shiftwidth = dst
|
|
vim.bo.tabstop = dst
|
|
vim.bo.expandtab = true
|
|
vim.cmd("%retab!")
|
|
end, { nargs = "+" })
|
|
|
|
vim.api.nvim_create_user_command("W", function() vim.cmd.w() end, {})
|