diff options
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r-- | runtime/doc/eval.txt | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 57ef380cc5..697e456817 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1010,8 +1010,9 @@ There must not be white space before or after the dot. Examples: > :let dict = {"one": 1, 2: "two"} - :echo dict.one - :echo dict .2 + :echo dict.one " shows "1" + :echo dict.2 " shows "two" + :echo dict .2 " error because of space before the dot Note that the dot is also used for String concatenation. To avoid confusion always put spaces around the dot for String concatenation. @@ -1588,7 +1589,7 @@ v:exception The value of the exception most recently caught and not :try : throw "oops" :catch /.*/ - : echo "caught" v:exception + : echo "caught " .. v:exception :endtry < Output: "caught oops". @@ -3982,7 +3983,10 @@ get({list}, {idx} [, {default}]) *get()* get({dict}, {key} [, {default}]) Get item with key {key} from |Dictionary| {dict}. When this item is not available return {default}. Return zero when - {default} is omitted. + {default} is omitted. Useful example: > + let val = get(g:, 'var_name', 'default') +< This gets the value of g:var_name if it exists, and uses + 'default' when it does not exist. get({func}, {what}) Get item {what} from Funcref {func}. Possible values for {what} are: @@ -5038,7 +5042,6 @@ iconv({expr}, {from}, {to}) *iconv()* Note that Vim uses UTF-8 for all Unicode encodings, conversion from/to UCS-2 is automatically changed to use UTF-8. You cannot use UCS-2 in a string anyway, because of the NUL bytes. - {only available when compiled with the |+multi_byte| feature} *indent()* indent({lnum}) The result is a Number, which is indent of line {lnum} in the @@ -5470,8 +5473,6 @@ libcall({libname}, {funcname}, {argument}) the DLL is not in the usual places. For Unix: When compiling your own plugins, remember that the object code must be compiled as position-independent ('PIC'). - {only in Win32 and some Unix versions, when the |+libcall| - feature is present} Examples: > :echo libcall("libc.so", "getenv", "HOME") < @@ -5479,8 +5480,6 @@ libcall({libname}, {funcname}, {argument}) libcallnr({libname}, {funcname}, {argument}) Just like |libcall()|, but used for a function that returns an int instead of a string. - {only in Win32 on some Unix versions, when the |+libcall| - feature is present} Examples: > :echo libcallnr("/usr/lib/libc.so", "getpid", "") :call libcallnr("libc.so", "printf", "Hello World!\n") @@ -6408,7 +6407,6 @@ py3eval({expr}) *py3eval()* Lists are represented as Vim |List| type. Dictionaries are represented as Vim |Dictionary| type with keys converted to strings. - {only available when compiled with the |+python3| feature} *E858* *E859* pyeval({expr}) *pyeval()* @@ -6419,7 +6417,6 @@ pyeval({expr}) *pyeval()* Lists are represented as Vim |List| type. Dictionaries are represented as Vim |Dictionary| type, non-string keys result in error. - {only available when compiled with the |+python| feature} pyxeval({expr}) *pyxeval()* Evaluate Python expression {expr} and return its result @@ -6553,7 +6550,6 @@ remote_expr({server}, {string} [, {idvar} [, {timeout}]]) seconds. Otherwise a timeout of 600 seconds is used. See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. - {only available when compiled with the |+clientserver| feature} Note: Any errors will cause a local error message to be issued and the result will be the empty string. @@ -6589,7 +6585,6 @@ remote_peek({serverid} [, {retvar}]) *remote_peek()* Returns -1 if something is wrong. See also |clientserver|. This function is not available in the |sandbox|. - {only available when compiled with the |+clientserver| feature} Examples: > :let repl = "" :echo "PEEK: ".remote_peek(id, "repl").": ".repl @@ -6600,7 +6595,6 @@ remote_read({serverid}, [{timeout}]) *remote_read()* reply is available. See also |clientserver|. This function is not available in the |sandbox|. - {only available when compiled with the |+clientserver| feature} Example: > :echo remote_read(id) < @@ -6614,7 +6608,6 @@ remote_send({server}, {string} [, {idvar}]) there. See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. - {only available when compiled with the |+clientserver| feature} Note: Any errors will be reported in the server and may mess up the display. @@ -6631,7 +6624,6 @@ remote_send({server}, {string} [, {idvar}]) remote_startserver({name}) Become the server {name}. This fails if already running as a server, when |v:servername| is not empty. - {only available when compiled with the |+clientserver| feature} remove({list}, {idx} [, {end}]) *remove()* Without {end}: Remove the item at {idx} from |List| {list} and @@ -6645,7 +6637,8 @@ remove({list}, {idx} [, {end}]) *remove()* :echo "last item: " . remove(mylist, -1) :call remove(mylist, 0, 9) remove({dict}, {key}) - Remove the entry from {dict} with key {key}. Example: > + Remove the entry from {dict} with key {key} and return it. + Example: > :echo "removed " . remove(dict, "one") < If there is no {key} in {dict} this is an error. @@ -6802,7 +6795,6 @@ search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* {timeout} is 500 the search stops after half a second. The value must not be negative. A zero value is like not giving the argument. - {only available when compiled with the |+reltime| feature} *search()-sub-match* With the 'p' flag the returned value is one more than the @@ -6978,7 +6970,6 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* server2client({clientid}, {string}) *server2client()* Send a reply string to {clientid}. The most recent {clientid} that sent a string can be retrieved with expand("<client>"). - {only available when compiled with the |+clientserver| feature} Note: This id has to be stored before the next command can be received. I.e. before returning from the received command and @@ -9328,7 +9319,7 @@ This function can then be called with: > *:cal* *:call* *E107* *E117* :[range]cal[l] {name}([arguments]) Call a function. The name of the function and its arguments - are as specified with |:function|. Up to 20 arguments can be + are as specified with `:function`. Up to 20 arguments can be used. The returned value is discarded. Without a range and for functions that accept a range, the function is called once. When a range is given the cursor is @@ -9382,9 +9373,9 @@ Using an autocommand ~ This is introduced in the user manual, section |41.14|. The autocommand is useful if you have a plugin that is a long Vim script file. -You can define the autocommand and quickly quit the script with |:finish|. +You can define the autocommand and quickly quit the script with `:finish`. That makes Vim startup faster. The autocommand should then load the same file -again, setting a variable to skip the |:finish| command. +again, setting a variable to skip the `:finish` command. Use the FuncUndefined autocommand event with a pattern that matches the function(s) to be defined. Example: > @@ -9699,6 +9690,11 @@ This does NOT work: > register values cannot be used here, since they cannot be locked. +:cons[t] +:cons[t] {var-name} + If no argument is given or only {var-name} is given, + the behavior is the same as |:let|. + :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* Lock the internal variable {name}. Locking means that it can no longer be changed (until it is unlocked). @@ -9750,7 +9746,7 @@ This does NOT work: > opposite of |:lockvar|. -:if {expr1} *:if* *:endif* *:en* *E171* *E579* *E580* +:if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580* :en[dif] Execute the commands until the next matching ":else" or ":endif" if {expr1} evaluates to non-zero. |