Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
17078:44dab1a4d0ef | 17079:00ffed9bbb65 |
---|---|
11596 Remove environment variable {env-name}. | 11596 Remove environment variable {env-name}. |
11597 Can mix {name} and ${env-name} in one :unlet command. | 11597 Can mix {name} and ${env-name} in one :unlet command. |
11598 No error message is given for a non-existing | 11598 No error message is given for a non-existing |
11599 variable, also without !. | 11599 variable, also without !. |
11600 If the system does not support deleting an environment | 11600 If the system does not support deleting an environment |
11601 variable, it is made emtpy. | 11601 variable, it is made empty. |
11602 | 11602 |
11603 *:cons* *:const* *E996* | |
11604 :cons[t] {var-name} = {expr1} | |
11605 :cons[t] [{name1}, {name2}, ...] = {expr1} | |
11606 :cons[t] [{name1}, {name2}, ...] .= {expr1} | |
11607 :cons[t] [{name}, ..., ; {lastname}] = {expr1} | |
11608 :cons[t] {var-name} =<< [trim] {marker} | |
11609 text... | |
11610 text... | |
11611 {marker} | |
11612 Similar to |:let|, but additionally lock the variable | |
11613 after setting the value. This is the same as locking | |
11614 the variable with |:lockvar| just after |:let|, thus: > | |
11615 :const x = 1 | |
11616 < is equivalent to: > | |
11617 :let x = 1 | |
11618 :lockvar 1 x | |
11619 < This is useful if you want to make sure the variable | |
11620 is not modified. | |
11621 *E995* | |
11622 |:const| does not allow to for changing a variable. > | |
11623 :let x = 1 | |
11624 :const x = 2 " Error! | |
11625 < | |
11603 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* | 11626 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* |
11604 Lock the internal variable {name}. Locking means that | 11627 Lock the internal variable {name}. Locking means that |
11605 it can no longer be changed (until it is unlocked). | 11628 it can no longer be changed (until it is unlocked). |
11606 A locked variable can be deleted: > | 11629 A locked variable can be deleted: > |
11607 :lockvar v | 11630 :lockvar v |