Mercurial > vim
diff runtime/doc/eval.txt @ 17079:00ffed9bbb65 v8.1.1539
patch 8.1.1539: not easy to define a variable and lock it
commit https://github.com/vim/vim/commit/9937a055437ef67b57a1bdec8f0799b669c9dbf0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 15 15:45:06 2019 +0200
patch 8.1.1539: not easy to define a variable and lock it
Problem: Not easy to define a variable and lock it.
Solution: Add ":const".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Jun 2019 16:00:05 +0200 |
parents | d5fa04016df0 |
children | 620e9011b685 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -11598,8 +11598,31 @@ text... No error message is given for a non-existing variable, also without !. If the system does not support deleting an environment - variable, it is made emtpy. - + variable, it is made empty. + + *:cons* *:const* *E996* +:cons[t] {var-name} = {expr1} +:cons[t] [{name1}, {name2}, ...] = {expr1} +:cons[t] [{name1}, {name2}, ...] .= {expr1} +:cons[t] [{name}, ..., ; {lastname}] = {expr1} +:cons[t] {var-name} =<< [trim] {marker} +text... +text... +{marker} + Similar to |:let|, but additionally lock the variable + after setting the value. This is the same as locking + the variable with |:lockvar| just after |:let|, thus: > + :const x = 1 +< is equivalent to: > + :let x = 1 + :lockvar 1 x +< This is useful if you want to make sure the variable + is not modified. + *E995* + |:const| does not allow to for changing a variable. > + :let x = 1 + :const x = 2 " Error! +< :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* Lock the internal variable {name}. Locking means that it can no longer be changed (until it is unlocked).