variables 

Send to Kindle
home » snippets » vim » variables



An internal variable name can be made up of letters, digits and '_'. But it cannot start with a digit. It's also possible to use curly braces, see curly-braces-names. An internal variable is created with the ":let" command. An internal variable is explicitly destroyed with the ":unlet". Using a name that is not an internal variable or refers to a variable that has been destroyed results in an error.

Prefixes

type prefix description
None In a function: local to a function; otherwise: global
buffer-variable b: Local to the current buffer.
window-variable w: Local to the current window.
tabpage-variable t: Local to the current tab page.
global-variable g: Global.
local-variable l: Local to a function.
script-variable s: Local to a
function-argument a: Function argument (only inside a function).
vim-variable v: Global, predefined by Vim.

The scope name by itself can be used as a Dictionary. For example, to delete all script-local variables:

for k in keys(s:)
    unlet s:[k]
endfor

Selected Variables

changedtick

See b:changedtick

b:changedtick
The total number of changes to the current buffer. It is incremented for each change. An undo command is also a change in this case.

This can be used to perform an action only when the buffer has changed.

Example:

:if my_changedtick != b:changedtick
:   let my_changedtick = b:changedtick
:   call My_Update()
:endif