vim.Option
Methods4
function Option.get() -> value nil | boolean | string | integer
Returns a Lua-representation of the option. Boolean, number and string values will be returned in exactly the same fashion.
For values that are comma-separated lists, an array will be returned with the values as entries in the array:
vim.cmd [[set wildignore=*.pyc,*.o]]
vim.print(vim.opt.wildignore:get())
-- { "*.pyc", "*.o", }
for _, ignore_pattern in ipairs(vim.opt.wildignore:get()) do
print("Will ignore:", ignore_pattern)
end
-- Will ignore: *.pyc
-- Will ignore: *.o
For values that are comma-separated maps, a table will be returned with the names as keys and the values as entries:
vim.cmd [[set listchars=space:_,tab:>~]]
vim.print(vim.opt.listchars:get())
-- { space = "_", tab = ">~", }
for char, representation in pairs(vim.opt.listchars:get()) do
print(char, "=>", representation)
end
For values that are lists of flags, a set will be returned with the flags as keys and true as entries.
vim.cmd [[set formatoptions=njtcroql]]
vim.print(vim.opt.formatoptions:get())
-- { n = true, j = true, c = true, ... }
local format_opts = vim.opt.formatoptions:get()
if format_opts.j then
print("J is enabled!")
end
Returns
valuenil | boolean | string | integerof option
function Option.append(value: string)
luacheck: no unused
Parameters
valuestringValue to append
function Option.prepend(value: string)
luacheck: no unused
Parameters
valuestringValue to prepend
function Option.remove(value: string)
luacheck: no unused
Parameters
valuestringValue to remove