Skip to main content
Version: 1.4

Options

Options are used to configure the editor, variables to configure vimscript plugins.

Neovim options

See :help lua-guide-options to learn more.

  • To set options:

    vim.opt.{option} = {value}
  • To get options:

    vim.opt.{option}:get()

Example options

vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages
vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 2 -- insert 2 spaces for a tab
vim.opt.relativenumber = true -- relative line numbers
vim.opt.wrap = true -- wrap lines

-- use treesitter folding
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"

Neovim variables

See :help lua-guide-variables to learn more.

  • To get and set variables use:

    vim.g.{name} -- global variables (g:)
    vim.b.{name} -- variables for the current buffer (b:)
    vim.w.{name} -- variables for the current window (w:)
    vim.t.{name} -- variables for the current tabpage (t:)
    vim.v.{name} -- predefined Vim variables (v:)
    vim.env.{name} -- environment variables defined in the editor session