A few meta-accessors are available if you want to set options in a more "idiomatic" way. They essentially wrap the above API functions and allow you to manipulate options as if they were variables:
A few meta-accessors are available if you want to set options in a more "idiomatic" way. They essentially wrap the above API functions and allow you to manipulate options as if they were variables:
- `vim.o.{option}`: global options
- `vim.o.{option}`: behaves like `:set`
- `vim.bo.{option}`: buffer-local options
- `vim.go.{option}`: behaves like `:setglobal`
- `vim.wo.{option}`: window-local options
- `vim.bo.{option}`: behaves like `:setlocal` for buffer-local options
- `vim.wo.{option}`: behaves like `:setlocal` for window-local options
```lua
```lua
vim.o.smarttab = false
vim.o.smarttab = false
print(vim.o.smarttab) -- false
print(vim.o.smarttab) -- false
vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@
vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@
@ -603,15 +604,6 @@ vim.wo.number = true -- same as vim.api.nvim_win_set_option(0, 'number', true)
See also:
See also:
- `:help lua-vim-options`
- `:help lua-vim-options`
#### Caveats
There is no equivalent to the `:set` command in Lua, you either set an option globally or locally. If you're setting options from your `init.lua`, some of them will require you to set both `vim.o.{option}` and `vim.{wo/bo}.{option}` to work properly.