comparison runtime/doc/eval.txt @ 531:da9142bd190a v7.0149

updated for version 7.0149
author vimboss
date Tue, 20 Sep 2005 23:22:24 +0000
parents 339999b511a0
children 7052f11a3dc9
comparison
equal deleted inserted replaced
530:339999b511a0 531:da9142bd190a
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Sep 15 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Sep 20
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
1518 getchar( [expr]) Number get one character from the user 1518 getchar( [expr]) Number get one character from the user
1519 getcharmod( ) Number modifiers for the last typed character 1519 getcharmod( ) Number modifiers for the last typed character
1520 getbufvar( {expr}, {varname}) variable {varname} in buffer {expr} 1520 getbufvar( {expr}, {varname}) variable {varname} in buffer {expr}
1521 getcmdline() String return the current command-line 1521 getcmdline() String return the current command-line
1522 getcmdpos() Number return cursor position in command-line 1522 getcmdpos() Number return cursor position in command-line
1523 getcmdtype() String return the current command-line type
1523 getcwd() String the current working directory 1524 getcwd() String the current working directory
1524 getfperm( {fname}) String file permissions of file {fname} 1525 getfperm( {fname}) String file permissions of file {fname}
1525 getfsize( {fname}) Number size in bytes of file {fname} 1526 getfsize( {fname}) Number size in bytes of file {fname}
1526 getfontname( [{name}]) String name of font being used 1527 getfontname( [{name}]) String name of font being used
1527 getftime( {fname}) Number last modification time of file 1528 getftime( {fname}) Number last modification time of file
1548 hostname() String name of the machine Vim is running on 1549 hostname() String name of the machine Vim is running on
1549 iconv( {expr}, {from}, {to}) String convert encoding of {expr} 1550 iconv( {expr}, {from}, {to}) String convert encoding of {expr}
1550 indent( {lnum}) Number indent of line {lnum} 1551 indent( {lnum}) Number indent of line {lnum}
1551 index( {list}, {expr} [, {start} [, {ic}]]) 1552 index( {list}, {expr} [, {start} [, {ic}]])
1552 Number index in {list} where {expr} appears 1553 Number index in {list} where {expr} appears
1553 input( {prompt} [, {text}]) String get input from the user 1554 input( {prompt} [, {text} [, {completion}]])
1555 String get input from the user
1554 inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog 1556 inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog
1555 inputrestore() Number restore typeahead 1557 inputrestore() Number restore typeahead
1556 inputsave() Number save and clear typeahead 1558 inputsave() Number save and clear typeahead
1557 inputsecret( {prompt} [, {text}]) String like input() but hiding the text 1559 inputsecret( {prompt} [, {text}]) String like input() but hiding the text
1558 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] 1560 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}]
2531 Return the current command-line. Only works when the command 2533 Return the current command-line. Only works when the command
2532 line is being edited, thus requires use of |c_CTRL-\_e| or 2534 line is being edited, thus requires use of |c_CTRL-\_e| or
2533 |c_CTRL-R_=|. 2535 |c_CTRL-R_=|.
2534 Example: > 2536 Example: >
2535 :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> 2537 :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
2536 < Also see |getcmdpos()| and |setcmdpos()|. 2538 < Also see |getcmdtype()|, |getcmdpos()| and |setcmdpos()|.
2537 2539
2538 getcmdpos() *getcmdpos()* 2540 getcmdpos() *getcmdpos()*
2539 Return the position of the cursor in the command line as a 2541 Return the position of the cursor in the command line as a
2540 byte count. The first column is 1. 2542 byte count. The first column is 1.
2541 Only works when editing the command line, thus requires use of 2543 Only works when editing the command line, thus requires use of
2542 |c_CTRL-\_e| or |c_CTRL-R_=|. Returns 0 otherwise. 2544 |c_CTRL-\_e| or |c_CTRL-R_=|. Returns 0 otherwise.
2543 Also see |setcmdpos()| and |getcmdline()|. 2545 Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|.
2546
2547 getcmdtype() *getcmdtype()*
2548 Return the current command-line type. Possible return values
2549 are:
2550 / Search forward command
2551 ? Search backward command
2552 : Ex-command mode
2553 @ Input mode
2554 > Debug mode
2555 Only works when editing the command line, thus requires use of
2556 |c_CTRL-\_e| or |c_CTRL-R_=|. Returns an empty string
2557 otherwise.
2558 Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
2544 2559
2545 *getcwd()* 2560 *getcwd()*
2546 getcwd() The result is a String, which is the name of the current 2561 getcwd() The result is a String, which is the name of the current
2547 working directory. 2562 working directory.
2548 2563
2908 Example: > 2923 Example: >
2909 :let idx = index(words, "the") 2924 :let idx = index(words, "the")
2910 :if index(numbers, 123) >= 0 2925 :if index(numbers, 123) >= 0
2911 2926
2912 2927
2913 input({prompt} [, {text}]) *input()* 2928 input({prompt} [, {text} [, {completion}]]) *input()*
2914 The result is a String, which is whatever the user typed on 2929 The result is a String, which is whatever the user typed on
2915 the command-line. The parameter is either a prompt string, or 2930 the command-line. The parameter is either a prompt string, or
2916 a blank string (for no prompt). A '\n' can be used in the 2931 a blank string (for no prompt). A '\n' can be used in the
2917 prompt to start a new line. The highlighting set with 2932 prompt to start a new line.
2918 |:echohl| is used for the prompt. The input is entered just 2933 The highlighting set with |:echohl| is used for the prompt.
2919 like a command-line, with the same editing commands and 2934 The input is entered just like a command-line, with the same
2920 mappings. There is a separate history for lines typed for 2935 editing commands and mappings. There is a separate history
2921 input(). 2936 for lines typed for input().
2937 Example: >
2938 :if input("Coffee or beer? ") == "beer"
2939 : echo "Cheers!"
2940 :endif
2941 <
2922 If the optional {text} is present, this is used for the 2942 If the optional {text} is present, this is used for the
2923 default reply, as if the user typed this. 2943 default reply, as if the user typed this. Example: >
2924 NOTE: This must not be used in a startup file, for the 2944 :let color = input("Color? ", "white")
2925 versions that only run in GUI mode (e.g., the Win32 GUI). 2945
2946 < The optional {completion} argument specifies the type of
2947 completion supported for the input. Without it completion is
2948 not performed. The supported completion types are the same as
2949 that can be supplied to a user-defined command using the
2950 "-complete=" argument. Refer to |:command-completion| for
2951 more information. Example: >
2952 let fname = input("File: ", "", "file")
2953 <
2954 NOTE: This function must not be used in a startup file, for
2955 the versions that only run in GUI mode (e.g., the Win32 GUI).
2926 Note: When input() is called from within a mapping it will 2956 Note: When input() is called from within a mapping it will
2927 consume remaining characters from that mapping, because a 2957 consume remaining characters from that mapping, because a
2928 mapping is handled like the characters were typed. 2958 mapping is handled like the characters were typed.
2929 Use |inputsave()| before input() and |inputrestore()| 2959 Use |inputsave()| before input() and |inputrestore()|
2930 after input() to avoid that. Another solution is to avoid 2960 after input() to avoid that. Another solution is to avoid
2931 that further characters follow in the mapping, e.g., by using 2961 that further characters follow in the mapping, e.g., by using
2932 |:execute| or |:normal|. 2962 |:execute| or |:normal|.
2933 2963
2934 Example: > 2964 Example with a mapping: >
2935 :if input("Coffee or beer? ") == "beer"
2936 : echo "Cheers!"
2937 :endif
2938 < Example with default text: >
2939 :let color = input("Color? ", "white")
2940 < Example with a mapping: >
2941 :nmap \x :call GetFoo()<CR>:exe "/" . Foo<CR> 2965 :nmap \x :call GetFoo()<CR>:exe "/" . Foo<CR>
2942 :function GetFoo() 2966 :function GetFoo()
2943 : call inputsave() 2967 : call inputsave()
2944 : let g:Foo = input("enter search pattern: ") 2968 : let g:Foo = input("enter search pattern: ")
2945 : call inputrestore() 2969 : call inputrestore()
2955 :endif 2979 :endif
2956 < When the dialog is cancelled {cancelreturn} is returned. When 2980 < When the dialog is cancelled {cancelreturn} is returned. When
2957 omitted an empty string is returned. 2981 omitted an empty string is returned.
2958 Hitting <Enter> works like pressing the OK button. Hitting 2982 Hitting <Enter> works like pressing the OK button. Hitting
2959 <Esc> works like pressing the Cancel button. 2983 <Esc> works like pressing the Cancel button.
2984 NOTE: Command-line completion is not supported.
2960 2985
2961 inputlist({textlist}) *inputlist()* 2986 inputlist({textlist}) *inputlist()*
2962 {textlist} must be a list of strings. This list is displayed, 2987 {textlist} must be a list of strings. This list is displayed,
2963 one string per line. The user will be prompted to enter a 2988 one string per line. The user will be prompted to enter a
2964 number, which is returned. 2989 number, which is returned.
2994 asterisks ("*") thereby keeping the entry secret, and 3019 asterisks ("*") thereby keeping the entry secret, and
2995 b) the user's response will not be recorded on the input 3020 b) the user's response will not be recorded on the input
2996 |history| stack. 3021 |history| stack.
2997 The result is a String, which is whatever the user actually 3022 The result is a String, which is whatever the user actually
2998 typed on the command-line in response to the issued prompt. 3023 typed on the command-line in response to the issued prompt.
3024 NOTE: Command-line completion is not supported.
2999 3025
3000 insert({list}, {item} [, {idx}]) *insert()* 3026 insert({list}, {item} [, {idx}]) *insert()*
3001 Insert {item} at the start of List {list}. 3027 Insert {item} at the start of List {list}.
3002 If {idx} is specified insert {item} before the item with index 3028 If {idx} is specified insert {item} before the item with index
3003 {idx}. If {idx} is zero it goes before the first item, just 3029 {idx}. If {idx} is zero it goes before the first item, just
4448 < 4474 <
4449 *winline()* 4475 *winline()*
4450 winline() The result is a Number, which is the screen line of the cursor 4476 winline() The result is a Number, which is the screen line of the cursor
4451 in the window. This is counting screen lines from the top of 4477 in the window. This is counting screen lines from the top of
4452 the window. The first line is one. 4478 the window. The first line is one.
4479 If the cursor was moved the view on the file will be updated
4480 first, this may cause a scroll.
4453 4481
4454 *winnr()* 4482 *winnr()*
4455 winnr([{arg}]) The result is a Number, which is the number of the current 4483 winnr([{arg}]) The result is a Number, which is the number of the current
4456 window. The top window has number 1. 4484 window. The top window has number 1.
4457 When the optional argument is "$", the number of the 4485 When the optional argument is "$", the number of the