comparison runtime/doc/eval.txt @ 17855:285f7a700185 v8.1.1924

patch 8.1.1924: using empty string for current buffer is unexpected Commit: https://github.com/vim/vim/commit/a8eee21e75324d199acb1663cb5009e03014a13a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 24 22:14:58 2019 +0200 patch 8.1.1924: using empty string for current buffer is unexpected Problem: Using empty string for current buffer is unexpected. Solution: Make the argument optional for bufname() and bufnr().
author Bram Moolenaar <Bram@vim.org>
date Sat, 24 Aug 2019 22:30:03 +0200
parents 73ddc462979d
children 4935244c1128
comparison
equal deleted inserted replaced
17854:9cd094b68fa5 17855:285f7a700185
2333 bufadd({name}) Number add a buffer to the buffer list 2333 bufadd({name}) Number add a buffer to the buffer list
2334 bufexists({expr}) Number |TRUE| if buffer {expr} exists 2334 bufexists({expr}) Number |TRUE| if buffer {expr} exists
2335 buflisted({expr}) Number |TRUE| if buffer {expr} is listed 2335 buflisted({expr}) Number |TRUE| if buffer {expr} is listed
2336 bufload({expr}) Number load buffer {expr} if not loaded yet 2336 bufload({expr}) Number load buffer {expr} if not loaded yet
2337 bufloaded({expr}) Number |TRUE| if buffer {expr} is loaded 2337 bufloaded({expr}) Number |TRUE| if buffer {expr} is loaded
2338 bufname({expr}) String Name of the buffer {expr} 2338 bufname([{expr}]) String Name of the buffer {expr}
2339 bufnr({expr} [, {create}]) Number Number of the buffer {expr} 2339 bufnr([{expr} [, {create}]]) Number Number of the buffer {expr}
2340 bufwinid({expr}) Number window ID of buffer {expr} 2340 bufwinid({expr}) Number window ID of buffer {expr}
2341 bufwinnr({expr}) Number window number of buffer {expr} 2341 bufwinnr({expr}) Number window number of buffer {expr}
2342 byte2line({byte}) Number line number at byte count {byte} 2342 byte2line({byte}) Number line number at byte count {byte}
2343 byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr} 2343 byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr}
2344 byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr} 2344 byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr}
3215 The {expr} argument is used like with |bufexists()|. 3215 The {expr} argument is used like with |bufexists()|.
3216 3216
3217 Can also be used as a |method|: > 3217 Can also be used as a |method|: >
3218 let loaded = 'somename'->bufloaded() 3218 let loaded = 'somename'->bufloaded()
3219 3219
3220 bufname({expr}) *bufname()* 3220 bufname([{expr}]) *bufname()*
3221 The result is the name of a buffer, as it is displayed by the 3221 The result is the name of a buffer, as it is displayed by the
3222 ":ls" command. 3222 ":ls" command.
3223 If {expr} is omitted the current buffer is used.
3223 If {expr} is a Number, that buffer number's name is given. 3224 If {expr} is a Number, that buffer number's name is given.
3224 Number zero is the alternate buffer for the current window. 3225 Number zero is the alternate buffer for the current window.
3225 If {expr} is a String, it is used as a |file-pattern| to match 3226 If {expr} is a String, it is used as a |file-pattern| to match
3226 with the buffer names. This is always done like 'magic' is 3227 with the buffer names. This is always done like 'magic' is
3227 set and 'cpoptions' is empty. When there is more than one 3228 set and 'cpoptions' is empty. When there is more than one
3249 bufname("file2") name of buffer where "file2" matches. 3250 bufname("file2") name of buffer where "file2" matches.
3250 < *buffer_name()* 3251 < *buffer_name()*
3251 Obsolete name: buffer_name(). 3252 Obsolete name: buffer_name().
3252 3253
3253 *bufnr()* 3254 *bufnr()*
3254 bufnr({expr} [, {create}]) 3255 bufnr([{expr} [, {create}]])
3255 The result is the number of a buffer, as it is displayed by 3256 The result is the number of a buffer, as it is displayed by
3256 the ":ls" command. For the use of {expr}, see |bufname()| 3257 the ":ls" command. For the use of {expr}, see |bufname()|
3257 above. 3258 above.
3258 If the buffer doesn't exist, -1 is returned. Or, if the 3259 If the buffer doesn't exist, -1 is returned. Or, if the
3259 {create} argument is present and not zero, a new, unlisted, 3260 {create} argument is present and not zero, a new, unlisted,
3260 buffer is created and its number is returned. 3261 buffer is created and its number is returned.
3261 bufnr("$") is the last buffer: > 3262 bufnr("$") is the last buffer: >
3262 :let last_buffer = bufnr("$") 3263 :let last_buffer = bufnr("$")
3263 < The result is a Number, which is the highest buffer number 3264 < The result is a Number, which is the highest buffer number
3264 of existing buffers. Note that not all buffers with a smaller 3265 of existing buffers. Note that not all buffers with a smaller
3265 number necessarily exist, because ":bwipeout" may have removed 3266 number necessarily exist, because ":bwipeout" may have removed
3266 them. Use bufexists() to test for the existence of a buffer. 3267 them. Use bufexists() to test for the existence of a buffer.
3267 3268
7199 prompt is. This can also be done asynchronously. 7200 prompt is. This can also be done asynchronously.
7200 The callback is invoked with one argument, which is the text 7201 The callback is invoked with one argument, which is the text
7201 that was entered at the prompt. This can be an empty string 7202 that was entered at the prompt. This can be an empty string
7202 if the user only typed Enter. 7203 if the user only typed Enter.
7203 Example: > 7204 Example: >
7204 call prompt_setcallback(bufnr(''), function('s:TextEntered')) 7205 call prompt_setcallback(bufnr(), function('s:TextEntered'))
7205 func s:TextEntered(text) 7206 func s:TextEntered(text)
7206 if a:text == 'exit' || a:text == 'quit' 7207 if a:text == 'exit' || a:text == 'quit'
7207 stopinsert 7208 stopinsert
7208 close 7209 close
7209 else 7210 else
7225 prompt_setprompt({buf}, {text}) *prompt_setprompt()* 7226 prompt_setprompt({buf}, {text}) *prompt_setprompt()*
7226 Set prompt for buffer {buf} to {text}. You most likely want 7227 Set prompt for buffer {buf} to {text}. You most likely want
7227 {text} to end in a space. 7228 {text} to end in a space.
7228 The result is only visible if {buf} has 'buftype' set to 7229 The result is only visible if {buf} has 'buftype' set to
7229 "prompt". Example: > 7230 "prompt". Example: >
7230 call prompt_setprompt(bufnr(''), 'command: ') 7231 call prompt_setprompt(bufnr(), 'command: ')
7231 < 7232 <
7232 prop_ functions are documented here: |text-prop-functions|. 7233 prop_ functions are documented here: |text-prop-functions|.
7233 7234
7234 pum_getpos() *pum_getpos()* 7235 pum_getpos() *pum_getpos()*
7235 If the popup menu (see |ins-completion-menu|) is not visible, 7236 If the popup menu (see |ins-completion-menu|) is not visible,