vimtricks.wiki Concise Vim tricks, one at a time.

How do I quickly evaluate and print a Lua expression in Neovim without calling print()?

Answer

:lua =expr

Explanation

In Neovim, prefixing a Lua expression with = on the :lua command line evaluates it and pretty-prints the result using vim.inspect. This is the fastest way to explore the Neovim API, inspect configuration values, or debug Lua code without writing a dedicated print statement.

How it works

  • :lua — execute Lua code in Neovim's embedded Lua runtime
  • =expr — the = prefix is syntactic sugar for print(vim.inspect(expr))

Without =, you would need:

:lua print(vim.inspect(vim.api.nvim_list_bufs()))

With =, this becomes:

:lua =vim.api.nvim_list_bufs()

Example

Inspect which buffers are open:

:lua =vim.api.nvim_list_bufs()

Output: { 1, 2, 5 }

Check the value of an option:

:lua =vim.o.tabstop

Output: 4

Inspect a complex object:

:lua =vim.lsp.get_clients()[1]

Output: a fully formatted table with all client fields.

Tips

  • This only works in Neovim; standard Vim does not have :lua
  • The = prefix uses vim.inspect internally, so nested tables and non-printable types are shown clearly
  • Combine with vim.fn to call Vimscript functions: :lua =vim.fn.expand('%:p')
  • Works interactively in the command line window (q:) too, making it ideal for exploratory sessions

Next

How do I jump to the Nth line from the top or bottom of the visible screen using a count with H and L?