comparison runtime/doc/eval.txt @ 24838:3f9053c21765 v8.2.2957

patch 8.2.2957: using getchar() in Vim9 script is problematic Commit: https://github.com/vim/vim/commit/3a7503c34c65ed15cc08deb5b54aaf2ea51525b4 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 7 18:29:17 2021 +0200 patch 8.2.2957: using getchar() in Vim9 script is problematic Problem: Using getchar() in Vim9 script is problematic. Solution: Add getcharstr(). (closes https://github.com/vim/vim/issues/8343)
author Bram Moolenaar <Bram@vim.org>
date Mon, 07 Jun 2021 18:30:04 +0200
parents 840665e74421
children fd37be6dc258
comparison
equal deleted inserted replaced
24837:a9c9ff4fb89b 24838:3f9053c21765
2592 getbufline({expr}, {lnum} [, {end}]) 2592 getbufline({expr}, {lnum} [, {end}])
2593 List lines {lnum} to {end} of buffer {expr} 2593 List lines {lnum} to {end} of buffer {expr}
2594 getbufvar({expr}, {varname} [, {def}]) 2594 getbufvar({expr}, {varname} [, {def}])
2595 any variable {varname} in buffer {expr} 2595 any variable {varname} in buffer {expr}
2596 getchangelist([{expr}]) List list of change list items 2596 getchangelist([{expr}]) List list of change list items
2597 getchar([expr]) Number get one character from the user 2597 getchar([expr]) Number or String
2598 get one character from the user
2598 getcharmod() Number modifiers for the last typed character 2599 getcharmod() Number modifiers for the last typed character
2599 getcharpos({expr}) List position of cursor, mark, etc. 2600 getcharpos({expr}) List position of cursor, mark, etc.
2600 getcharsearch() Dict last character search 2601 getcharsearch() Dict last character search
2602 getcharstr([expr]) String get one character from the user
2601 getcmdline() String return the current command-line 2603 getcmdline() String return the current command-line
2602 getcmdpos() Number return cursor position in command-line 2604 getcmdpos() Number return cursor position in command-line
2603 getcmdtype() String return current command-line type 2605 getcmdtype() String return current command-line type
2604 getcmdwintype() String return current command-line window type 2606 getcmdwintype() String return current command-line window type
2605 getcompletion({pat}, {type} [, {filtered}]) 2607 getcompletion({pat}, {type} [, {filtered}])
5230 If [expr] is omitted, wait until a character is available. 5232 If [expr] is omitted, wait until a character is available.
5231 If [expr] is 0, only get a character when one is available. 5233 If [expr] is 0, only get a character when one is available.
5232 Return zero otherwise. 5234 Return zero otherwise.
5233 If [expr] is 1, only check if a character is available, it is 5235 If [expr] is 1, only check if a character is available, it is
5234 not consumed. Return zero if no character available. 5236 not consumed. Return zero if no character available.
5237 If you prefer always getting a string use |getcharstr()|.
5235 5238
5236 Without [expr] and when [expr] is 0 a whole character or 5239 Without [expr] and when [expr] is 0 a whole character or
5237 special key is returned. If it is a single character, the 5240 special key is returned. If it is a single character, the
5238 result is a number. Use nr2char() to convert it to a String. 5241 result is a number. Use nr2char() to convert it to a String.
5239 Otherwise a String is returned with the encoded character. 5242 Otherwise a String is returned with the encoded character.
5354 forward/backward regardless of the direction of the previous 5357 forward/backward regardless of the direction of the previous
5355 character search: > 5358 character search: >
5356 :nnoremap <expr> ; getcharsearch().forward ? ';' : ',' 5359 :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
5357 :nnoremap <expr> , getcharsearch().forward ? ',' : ';' 5360 :nnoremap <expr> , getcharsearch().forward ? ',' : ';'
5358 < Also see |setcharsearch()|. 5361 < Also see |setcharsearch()|.
5362
5363
5364 getcharstr([expr]) *getcharstr()*
5365 Get a single character from the user or input stream as a
5366 string.
5367 If [expr] is omitted, wait until a character is available.
5368 If [expr] is 0 or false, only get a character when one is
5369 available. Return an empty string otherwise.
5370 If [expr] is 1 or true, only check if a character is
5371 available, it is not consumed. Return an empty string
5372 if no character is available.
5373 Otherwise this works like |getchar()|, except that a number
5374 result is converted to a string.
5375
5359 5376
5360 getcmdline() *getcmdline()* 5377 getcmdline() *getcmdline()*
5361 Return the current command-line. Only works when the command 5378 Return the current command-line. Only works when the command
5362 line is being edited, thus requires use of |c_CTRL-\_e| or 5379 line is being edited, thus requires use of |c_CTRL-\_e| or
5363 |c_CTRL-R_=|. 5380 |c_CTRL-R_=|.