4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
10 Patch 6.2.186 (after 6.2.185)
11 Problem: Documentation file eval.txt contains examples without indent.
12 Solution: Insert the indent. Also fix other mistakes.
13 Files: runtime/doc/eval.txt
16 *** ../vim-6.2.185/runtime/doc/eval.txt Sun Jan 18 20:46:13 2004
17 --- runtime/doc/eval.txt Sun Jan 18 20:38:41 2004
21 String "foo" --> Number 0
22 String "0xf1" --> Number 241
23 String "0100" --> Number 64
24 + String "-8" --> Number -8
25 + String "+8" --> Number 0
27 To force conversion from String to Number, add zero to it: >
32 ".." indicates that the operations in this level can be concatenated.
34 ! &nu || &list && &shell == "csh"
36 All expressions within one level are parsed from left to right.
40 ".." indicates that the operations in this level can be concatenated.
42 ! &nu || &list && &shell == "csh"
44 All expressions within one level are parsed from left to right.
48 non-zero, the result is the value of the expression between the '?' and ':',
49 otherwise the result is the value of the expression after the ':'.
51 ! :echo lnum == 1 ? "top" : lnum
53 Since the first expression is an "expr2", it cannot contain another ?:. The
54 other two expressions can, thus allow for recursive use of ?:.
56 ! :echo lnum == 1 ? "top" : lnum == 1000 ? "last" : lnum
58 To keep this readable, using |line-continuation| is suggested: >
66 expr2 and expr3 *expr2* *expr3*
68 non-zero, the result is the value of the expression between the '?' and ':',
69 otherwise the result is the value of the expression after the ':'.
71 ! :echo lnum == 1 ? "top" : lnum
73 Since the first expression is an "expr2", it cannot contain another ?:. The
74 other two expressions can, thus allow for recursive use of ?:.
76 ! :echo lnum == 1 ? "top" : lnum == 1000 ? "last" : lnum
78 To keep this readable, using |line-continuation| is suggested: >
86 expr2 and expr3 *expr2* *expr3*
90 The operators can be concatenated, for example: >
92 ! &nu || &list && &shell == "csh"
94 Note that "&&" takes precedence over "||", so this has the meaning of: >
96 ! &nu || (&list && &shell == "csh")
98 Once the result is known, the expression "short-circuits", that is, further
99 arguments are not evaluated. This is like what happens in C. For example: >
104 This is valid even if there is no variable called "b" because "a" is non-zero,
105 so the result must be non-zero. Similarly below: >
107 ! echo exists("b") && b == "yes"
109 This is valid whether "b" has been defined or not. The second clause will
110 only be evaluated if "b" has been defined.
113 The operators can be concatenated, for example: >
115 ! &nu || &list && &shell == "csh"
117 Note that "&&" takes precedence over "||", so this has the meaning of: >
119 ! &nu || (&list && &shell == "csh")
121 Once the result is known, the expression "short-circuits", that is, further
122 arguments are not evaluated. This is like what happens in C. For example: >
127 This is valid even if there is no variable called "b" because "a" is non-zero,
128 so the result must be non-zero. Similarly below: >
130 ! echo exists("b") && b == "yes"
132 This is valid whether "b" has been defined or not. The second clause will
133 only be evaluated if "b" has been defined.
137 expr9[expr1] index in String *expr-[]* *E111*
139 ! This results in a String that contains the expr1'th single character from
140 ! expr9. expr9 is used as a String, expr1 as a Number.
142 Note that index zero gives the first character. This is like it works in C.
143 Careful: text column numbers start with one! Example, to get the character
145 ! :let c = getline(line("."))[col(".") - 1]
147 If the length of the String is less than the index, the result is an empty
151 expr9[expr1] index in String *expr-[]* *E111*
153 ! This results in a String that contains the expr1'th single byte from expr9.
154 ! expr9 is used as a String, expr1 as a Number. Note that this doesn't work for
155 ! multi-byte encodings.
157 Note that index zero gives the first character. This is like it works in C.
158 Careful: text column numbers start with one! Example, to get the character
160 ! :let c = getline(line("."))[col(".") - 1]
162 If the length of the String is less than the index, the result is an empty
167 The result is the contents of the named register, as a single string.
168 Newlines are inserted where required. To get the contents of the unnamed
169 ! register use @@. The '=' register can not be used here. See |registers| for
170 ! an explanation of the available registers.
173 nesting *expr-nesting* *E110*
176 The result is the contents of the named register, as a single string.
177 Newlines are inserted where required. To get the contents of the unnamed
178 ! register use @" or @@. The '=' register can not be used here. See
179 ! |registers| for an explanation of the available registers.
182 nesting *expr-nesting* *E110*
185 the environment variables known inside the current Vim session. If that
186 fails, a shell will be used to expand the variable. This can be slow, but it
187 does expand all variables that the shell knows about. Example: >
189 ! :echo expand("$version")
190 The first one probably doesn't echo anything, the second echoes the $version
191 variable (if your shell supports it).
194 the environment variables known inside the current Vim session. If that
195 fails, a shell will be used to expand the variable. This can be slow, but it
196 does expand all variables that the shell knows about. Example: >
198 ! :echo expand("$version")
199 The first one probably doesn't echo anything, the second echoes the $version
200 variable (if your shell supports it).
206 script variables can be used to avoid conflicts with global variable names.
207 ! An example that works: >
214 script variables can be used to avoid conflicts with global variable names.
222 command Tick call MyCounter()
224 ! And an example that does NOT work: >
227 command Tick let s:counter = s:counter + 1 | echo s:counter
229 ! When the ":Tick" command is executed outside the script, the s:counter
230 ! variable will not be available. In the previous example, calling the
231 ! MyCounter() function sets the context for script variables to where the
232 ! function was defined, then s:counter can be used.
233 The script variables are also available when a function is defined inside a
234 function that is defined in a script. Example: >
238 command Tick call MyCounter()
240 ! You can now invoke "Tick" from any script, and the "s:counter" variable in
241 ! that script will not be changed, only the "s:counter" in the script where
242 ! "Tick" was defined is used.
244 ! Another example that does the same: >
247 command Tick let s:counter = s:counter + 1 | echo s:counter
249 ! When calling a function and invoking a user-defined command, the context for
250 ! script varialbes is set to the script where the function or command was
253 The script variables are also available when a function is defined inside a
254 function that is defined in a script. Example: >
259 : echo "caught" v:exception
261 ! < Output: "caught oops"
263 *v:fname_in* *fname_in-variable*
264 v:fname_in The name of the input file. Only valid while evaluating:
267 : echo "caught" v:exception
269 ! < Output: "caught oops".
271 *v:fname_in* *fname_in-variable*
272 v:fname_in The name of the input file. Only valid while evaluating:
275 escape( {string}, {chars}) String escape {chars} in {string} with '\'
276 eventhandler( ) Number TRUE if inside an event handler
277 executable( {expr}) Number 1 if executable {expr} exists
278 ! exists( {var}) Number TRUE if {var} exists
279 expand( {expr}) String expand special keywords in {expr}
280 filereadable( {file}) Number TRUE if {file} is a readable file
281 filewritable( {file}) Number TRUE if {file} is a writable file
283 escape( {string}, {chars}) String escape {chars} in {string} with '\'
284 eventhandler( ) Number TRUE if inside an event handler
285 executable( {expr}) Number 1 if executable {expr} exists
286 ! exists( {expr}) Number TRUE if {expr} exists
287 expand( {expr}) String expand special keywords in {expr}
288 filereadable( {file}) Number TRUE if {file} is a readable file
289 filewritable( {file}) Number TRUE if {file} is a writable file
293 If {expr} is a Number, that buffer number's name is given.
294 Number zero is the alternate buffer for the current window.
295 ! If {expr} is a String, it is used as a regexp pattern to match
296 with the buffer names. This is always done like 'magic' is
297 set and 'cpoptions' is empty. When there is more than one
298 match an empty string is returned.
301 If {expr} is a Number, that buffer number's name is given.
302 Number zero is the alternate buffer for the current window.
303 ! If {expr} is a String, it is used as a |file-pattern| to match
304 with the buffer names. This is always done like 'magic' is
305 set and 'cpoptions' is empty. When there is more than one
306 match an empty string is returned.
309 window associated with buffer {expr}. For the use of {expr},
310 see |bufname()| above. If buffer {expr} doesn't exist or
311 there is no such window, -1 is returned. Example: >
312 echo "A window containing buffer 1 is " . (bufwinnr(1))
314 byte2line({byte}) *byte2line()*
315 Return the line number that contains the character at byte
316 count {byte} in the current buffer. This includes the
318 window associated with buffer {expr}. For the use of {expr},
319 see |bufname()| above. If buffer {expr} doesn't exist or
320 there is no such window, -1 is returned. Example: >
322 echo "A window containing buffer 1 is " . (bufwinnr(1))
324 ! < The number can be used with |CTRL-W_w| and ":wincmd w"
328 byte2line({byte}) *byte2line()*
329 Return the line number that contains the character at byte
330 count {byte} in the current buffer. This includes the
334 number of characters in the cursor line plus one)
335 'x position of mark x (if the mark is not set, 0 is
337 + For the screen column position use |virtcol()|.
338 Note that only marks in the current file can be used.
340 col(".") column of cursor
344 confirm("Save changes?", "&Yes\n&No\n&Cancel")
345 < The letter after the '&' is the shortcut key for that choice.
346 ! Thus you can type 'c' to select "Cancel". The shorcut does
347 not need to be the first letter: >
348 confirm("file has been modified", "&Save\nSave &All")
349 < For the console, the first letter of each choice is used as
352 confirm("Save changes?", "&Yes\n&No\n&Cancel")
353 < The letter after the '&' is the shortcut key for that choice.
354 ! Thus you can type 'c' to select "Cancel". The shortcut does
355 not need to be the first letter: >
356 confirm("file has been modified", "&Save\nSave &All")
357 < For the console, the first letter of each choice is used as
360 # pid database name prepend path
361 0 27664 cscope.out /usr/local
363 ! Invokation Return Val ~
364 ---------- ---------- >
365 cscope_connection() 1
366 cscope_connection(1, "out") 1
368 # pid database name prepend path
369 0 27664 cscope.out /usr/local
371 ! Invocation Return Val ~
372 ---------- ---------- >
373 cscope_connection() 1
374 cscope_connection(1, "out") 1
377 When editing another file, the counter is reset, thus this
378 really checks if the FileType event has been triggered for the
379 current buffer. This allows an autocommand that starts
380 ! editing another buffer to set 'filetype' and load a sytnax
383 escape({string}, {chars}) *escape()*
385 When editing another file, the counter is reset, thus this
386 really checks if the FileType event has been triggered for the
387 current buffer. This allows an autocommand that starts
388 ! editing another buffer to set 'filetype' and load a syntax
391 escape({string}, {chars}) *escape()*
394 -1 not implemented on this system
397 ! exists({expr}) The result is a Number, which is non-zero if {var} is defined,
398 ! zero otherwise. The {expr} argument is a string, which
399 ! contains one of these:
400 &option-name Vim option (only checks if it exists,
401 not if it really works)
402 +option-name Vim option that works.
404 -1 not implemented on this system
407 ! exists({expr}) The result is a Number, which is non-zero if {expr} is
408 ! defined, zero otherwise. The {expr} argument is a string,
409 ! which contains one of these:
410 &option-name Vim option (only checks if it exists,
411 not if it really works)
412 +option-name Vim option that works.
415 varname internal variable (see
416 |internal-variables|). Does not work
417 for |curly-braces-names|.
418 ! :cmdname Ex command, both built-in and user
419 ! commands |:command|
421 1 for match with start of a command
422 2 full match with a command
423 3 matches several user commands
425 varname internal variable (see
426 |internal-variables|). Does not work
427 for |curly-braces-names|.
428 ! :cmdname Ex command: built-in command, user
429 ! command or command modifier |:command|.
431 1 for match with start of a command
432 2 full match with a command
433 3 matches several user commands
437 literally and compared to the
438 autocommand patterns character by
440 + For checking for a supported feature use |has()|.
446 variables that are only known in a shell. But this can be
447 slow, because a shell must be started. See |expr-env-expand|.
448 The expanded variable is still handled like a list of file
451 See |glob()| for finding existing files. See |system()| for
452 getting the raw output of an external command.
454 variables that are only known in a shell. But this can be
455 slow, because a shell must be started. See |expr-env-expand|.
456 The expanded variable is still handled like a list of file
457 ! names. When an environment variable cannot be expanded, it is
458 ! left unchanged. Thus ":echo expand('$FOOBAR')" results in
461 See |glob()| for finding existing files. See |system()| for
462 getting the raw output of an external command.
465 returned. It doesn't matter if the folds are open or closed.
466 When used while updating folds (from 'foldexpr') -1 is
467 returned for lines where folds are still to be updated and the
468 ! foldlevel is unknown.
471 foldtext() Returns a String, to be displayed for a closed fold. This is
473 returned. It doesn't matter if the folds are open or closed.
474 When used while updating folds (from 'foldexpr') -1 is
475 returned for lines where folds are still to be updated and the
476 ! foldlevel is unknown. As a special case the level of the
477 ! previous line is usually available.
480 foldtext() Returns a String, to be displayed for a closed fold. This is
484 has({feature}) The result is a Number, which is 1 if the feature {feature} is
485 supported, zero otherwise. The {feature} argument is a
486 string. See |feature-list| below.
487 + Also see |exists()|.
489 hasmapto({what} [, {mode}]) *hasmapto()*
490 The result is a Number, which is 1 if there is a mapping that
493 without the ".DLL" suffix. A full path is only required if
494 the DLL is not in the usual places.
495 For Unix: When compiling your own plugins, remember that the
496 ! object code must be compiled as position-independant ('PIC').
497 {only in Win32 on some Unix versions, when the |+libcall|
501 without the ".DLL" suffix. A full path is only required if
502 the DLL is not in the usual places.
503 For Unix: When compiling your own plugins, remember that the
504 ! object code must be compiled as position-independent ('PIC').
505 {only in Win32 on some Unix versions, when the |+libcall|
511 nr2char(32) returns " "
512 < The current 'encoding' is used. Example for "utf-8": >
513 nr2char(300) returns I with bow character
514 + < Note that a NUL character in the file is specified with
515 + nr2char(10), because NULs are represented with newline
516 + characters. nr2char(0) is a real NUL and terminates the
517 + string, thus isn't very useful.
519 prevnonblank({lnum}) *prevnonblank()*
520 Return the line number of the first line at or above {lnum}
524 :s/\d\+/\=submatch(0) + 1/
525 < This finds the first number in the line and adds one to it.
526 ! Line breaks are included as a newline character.
528 substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
529 The result is a String, which is a copy of {expr}, in which
532 :s/\d\+/\=submatch(0) + 1/
533 < This finds the first number in the line and adds one to it.
534 ! A line break is included as a newline character.
536 substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
537 The result is a String, which is a copy of {expr}, in which
541 position, the returned Number will be the column at the end of
542 the <Tab>. For example, for a <Tab> in column 1, with 'ts'
543 set to 8, it returns 8.
544 + For the byte position use |col()|.
545 When Virtual editing is active in the current mode, a position
546 beyond the end of the line can be returned. |'virtualedit'|
547 The accepted positions are:
553 ! : exe "echo a:" . idx
561 ! : echo a:{idx} . ' '
570 ! : exe "let g:" . a:divname . " = ". a:n1 / a:n2
578 ! : let g:{a:divname} = a:n1 / a:n2
586 When using many or large functions, it's possible to automatically define them
587 ! only when they are used. Example: >
589 :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim
594 When using many or large functions, it's possible to automatically define them
595 ! only when they are used. Use the FuncUndefined autocommand event with a
596 ! pattern that matches the function(s) to be defined. Example: >
598 :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim
605 ! :ec[ho] {expr1} .. Echoes each {expr1}, with a space in between and a
606 ! terminating <EOL>. Also see |:comment|.
607 Use "\n" to start a new line. Use "\r" to move the
608 cursor to the first column.
609 Uses the highlighting set by the |:echohl| command.
614 ! :ec[ho] {expr1} .. Echoes each {expr1}, with a space in between. The
615 ! first {expr1} starts on a new line.
616 ! Also see |:comment|.
617 Use "\n" to start a new line. Use "\r" to move the
618 cursor to the first column.
619 Uses the highlighting set by the |:echohl| command.
622 Exceptions can be caught or can cause cleanup code to be executed. You can
623 use a try conditional to specify catch clauses (that catch exceptions) and/or
624 a finally clause (to be executed for cleanup).
625 ! A try conditional begins with a |:try| command and ends at the matching
626 |:endtry| command. In between, you can use a |:catch| command to start
627 a catch clause, or a |:finally| command to start a finally clause. There may
628 be none or multiple catch clauses, but there is at most one finally clause,
630 Exceptions can be caught or can cause cleanup code to be executed. You can
631 use a try conditional to specify catch clauses (that catch exceptions) and/or
632 a finally clause (to be executed for cleanup).
633 ! A try conditional begins with a |:try| command and ends at the matching
634 |:endtry| command. In between, you can use a |:catch| command to start
635 a catch clause, or a |:finally| command to start a finally clause. There may
636 be none or multiple catch clauses, but there is at most one finally clause,
639 For examples see |throw-catch|.
642 ! EXAMINIG EXCEPTION HANDLING CODE *except-examine*
644 Exception handling code can get tricky. If you are in doubt what happens, set
645 'verbose' to 13 or use the ":13verbose" command modifier when sourcing your
647 For examples see |throw-catch|.
650 ! EXAMINING EXCEPTION HANDLING CODE *except-examine*
652 Exception handling code can get tricky. If you are in doubt what happens, set
653 'verbose' to 13 or use the ":13verbose" command modifier when sourcing your
659 ! This code displays >
661 ! Vim(echoerr):Vim:E492: Not an editor command: asdf
664 CLEANUP CODE *try-finally*
671 ! Vim(echoerr):Vim:E492: Not an editor command: asdf ~
674 CLEANUP CODE *try-finally*
677 failed, if known. See |catch-errors|.
682 The exception handling concept requires that the command sequence causing the
683 exception is aborted immediately and control is transferred to finally clauses
685 failed, if known. See |catch-errors|.
690 The exception handling concept requires that the command sequence causing the
691 exception is aborted immediately and control is transferred to finally clauses
695 : echo "You will _never_ see this message"
698 ==============================================================================
699 11. The sandbox *eval-sandbox* *sandbox* *E48*
703 : echo "You will _never_ see this message"
706 ==============================================================================
707 11. The sandbox *eval-sandbox* *sandbox* *E48*
709 *** ../vim-6.2.185/src/version.c Sun Jan 18 20:46:13 2004
710 --- src/version.c Sun Jan 18 20:47:55 2004
714 { /* Add new patch number below this line */
720 ARTHUR: Well, I can't just call you `Man'.
721 DENNIS: Well, you could say `Dennis'.
722 ARTHUR: Well, I didn't know you were called `Dennis.'
723 DENNIS: Well, you didn't bother to find out, did you?
724 The Quest for the Holy Grail (Monty Python)
726 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
727 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
728 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
729 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///