Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to view variables in Vim

📅 2010-Nov-26 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ variable, vim ⬩ 📚 Archive

To view the list of all variables and their values in Vim:

:let

Note that this does not list environment variables, this post shows how to view those.

If you find it hard to wade through the long list, you can redirect the output of this command to a buffer for further analysis. For example, to load the output of :let into a buffer:

:redir @a
:let
:redir END
"ap

There are many types of variables in Vim and each has a special name or prefix:

g:  global variables
b:  local buffer variables
w:  local window variables
t:  local tab page variables
s:  script-local variables
l:  local function variables
v:  Vim variables.

To list the variables of a particular type, for example global variables, just use its prefix:

:let g:

Tried with: Vim 7.3 and Ubuntu 12.04 LTS