comparison runtime/doc/eval.txt @ 18000:7a19c8d6bb9e v8.1.1996

patch 8.1.1996: more functions can be used as methods Commit: https://github.com/vim/vim/commit/aad222c9c9a1e4fe6ae5a1fe95bb084619be0e65 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 6 22:46:09 2019 +0200 patch 8.1.1996: more functions can be used as methods Problem: More functions can be used as methods. Solution: Make various functions usable as a method.
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 Sep 2019 23:00:03 +0200
parents 0dcc2ee838dd
children 8ae333756614
comparison
equal deleted inserted replaced
17999:9fd4d58b3e5b 18000:7a19c8d6bb9e
1 *eval.txt* For Vim version 8.1. Last change: 2019 Sep 04 1 *eval.txt* For Vim version 8.1. Last change: 2019 Sep 06
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
3152 Add a buffer to the buffer list with {name}. 3152 Add a buffer to the buffer list with {name}.
3153 If a buffer for file {name} already exists, return that buffer 3153 If a buffer for file {name} already exists, return that buffer
3154 number. Otherwise return the buffer number of the newly 3154 number. Otherwise return the buffer number of the newly
3155 created buffer. When {name} is an empty string then a new 3155 created buffer. When {name} is an empty string then a new
3156 buffer is always created. 3156 buffer is always created.
3157 The buffer will not have' 'buflisted' set and not be loaded 3157 The buffer will not have 'buflisted' set and not be loaded
3158 yet. To add some text to the buffer use this: > 3158 yet. To add some text to the buffer use this: >
3159 let bufnr = bufadd('someName') 3159 let bufnr = bufadd('someName')
3160 call bufload(bufnr) 3160 call bufload(bufnr)
3161 call setbufline(bufnr, 1, ['some', 'text']) 3161 call setbufline(bufnr, 1, ['some', 'text'])
3162 < Can also be used as a |method|: > 3162 < Can also be used as a |method|: >
6463 {buf} refers to a buffer name or number. For the accepted 6463 {buf} refers to a buffer name or number. For the accepted
6464 values, see |bufname()|. When {buf} is omitted the current 6464 values, see |bufname()|. When {buf} is omitted the current
6465 buffer is used. 6465 buffer is used.
6466 Returns a unique ID that can be passed to |listener_remove()|. 6466 Returns a unique ID that can be passed to |listener_remove()|.
6467 6467
6468 The {callback} is invoked with four arguments: 6468 The {callback} is invoked with five arguments:
6469 a:bufnr the buffer that was changed 6469 a:bufnr the buffer that was changed
6470 a:start first changed line number 6470 a:start first changed line number
6471 a:end first line number below the change 6471 a:end first line number below the change
6472 a:added total number of lines added, negative if lines 6472 a:added total number of lines added, negative if lines
6473 were deleted 6473 were deleted
8394 8394
8395 If the optional {what} dictionary argument is supplied, then 8395 If the optional {what} dictionary argument is supplied, then
8396 only the items listed in {what} are set. Refer to |setqflist()| 8396 only the items listed in {what} are set. Refer to |setqflist()|
8397 for the list of supported keys in {what}. 8397 for the list of supported keys in {what}.
8398 8398
8399 Can also be used as a |method|, the base is passed as the
8400 second argument: >
8401 GetLoclist()->setloclist(winnr)
8402
8399 setmatches({list} [, {win}]) *setmatches()* 8403 setmatches({list} [, {win}]) *setmatches()*
8400 Restores a list of matches saved by |getmatches() for the 8404 Restores a list of matches saved by |getmatches() for the
8401 current window|. Returns 0 if successful, otherwise -1. All 8405 current window|. Returns 0 if successful, otherwise -1. All
8402 current matches are cleared before the list is restored. See 8406 current matches are cleared before the list is restored. See
8403 example for |getmatches()|. 8407 example for |getmatches()|.
8404 If {win} is specified, use the window with this number or 8408 If {win} is specified, use the window with this number or
8405 window ID instead of the current window. 8409 window ID instead of the current window.
8406 8410
8411 Can also be used as a |method|: >
8412 GetMatches()->setmatches()
8413 <
8407 *setpos()* 8414 *setpos()*
8408 setpos({expr}, {list}) 8415 setpos({expr}, {list})
8409 Set the position for {expr}. Possible values: 8416 Set the position for {expr}. Possible values:
8410 . the cursor 8417 . the cursor
8411 'x mark x 8418 'x mark x
8450 This does not restore the preferred column for moving 8457 This does not restore the preferred column for moving
8451 vertically; if you set the cursor position with this, |j| and 8458 vertically; if you set the cursor position with this, |j| and
8452 |k| motions will jump to previous columns! Use |cursor()| to 8459 |k| motions will jump to previous columns! Use |cursor()| to
8453 also set the preferred column. Also see the "curswant" key in 8460 also set the preferred column. Also see the "curswant" key in
8454 |winrestview()|. 8461 |winrestview()|.
8462
8463 Can also be used as a |method|: >
8464 GetPosition()->setpos('.')
8455 8465
8456 setqflist({list} [, {action} [, {what}]]) *setqflist()* 8466 setqflist({list} [, {action} [, {what}]]) *setqflist()*
8457 Create or replace or add to the quickfix list. 8467 Create or replace or add to the quickfix list.
8458 8468
8459 When {what} is not present, use the items in {list}. Each 8469 When {what} is not present, use the items in {list}. Each
8552 8562
8553 This function can be used to create a quickfix list 8563 This function can be used to create a quickfix list
8554 independent of the 'errorformat' setting. Use a command like 8564 independent of the 'errorformat' setting. Use a command like
8555 `:cc 1` to jump to the first position. 8565 `:cc 1` to jump to the first position.
8556 8566
8557 8567 Can also be used as a |method|, the base is passed as the
8568 second argument: >
8569 GetErrorlist()->setqflist()
8570 <
8558 *setreg()* 8571 *setreg()*
8559 setreg({regname}, {value} [, {options}]) 8572 setreg({regname}, {value} [, {options}])
8560 Set the register {regname} to {value}. 8573 Set the register {regname} to {value}.
8561 {value} may be any value returned by |getreg()|, including 8574 {value} may be any value returned by |getreg()|, including
8562 a |List|. 8575 a |List|.
8600 8613
8601 You can also change the type of a register by appending 8614 You can also change the type of a register by appending
8602 nothing: > 8615 nothing: >
8603 :call setreg('a', '', 'al') 8616 :call setreg('a', '', 'al')
8604 8617
8618 < Can also be used as a |method|, the base is passed as the
8619 second argument: >
8620 GetText()->setreg('a')
8621
8605 settabvar({tabnr}, {varname}, {val}) *settabvar()* 8622 settabvar({tabnr}, {varname}, {val}) *settabvar()*
8606 Set tab-local variable {varname} to {val} in tab page {tabnr}. 8623 Set tab-local variable {varname} to {val} in tab page {tabnr}.
8607 |t:var| 8624 |t:var|
8608 Note that autocommands are blocked, side effects may not be 8625 Note that autocommands are blocked, side effects may not be
8609 triggered, e.g. when setting 'filetype'. 8626 triggered, e.g. when setting 'filetype'.
8610 Note that the variable name without "t:" must be used. 8627 Note that the variable name without "t:" must be used.
8611 Tabs are numbered starting with one. 8628 Tabs are numbered starting with one.
8612 This function is not available in the |sandbox|. 8629 This function is not available in the |sandbox|.
8630
8631 Can also be used as a |method|, the base is used as the value: >
8632 GetValue()->settabvar(tab, name)
8613 8633
8614 settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()* 8634 settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
8615 Set option or local variable {varname} in window {winnr} to 8635 Set option or local variable {varname} in window {winnr} to
8616 {val}. 8636 {val}.
8617 Tabs are numbered starting with one. For the current tabpage 8637 Tabs are numbered starting with one. For the current tabpage
8627 Examples: > 8647 Examples: >
8628 :call settabwinvar(1, 1, "&list", 0) 8648 :call settabwinvar(1, 1, "&list", 0)
8629 :call settabwinvar(3, 2, "myvar", "foobar") 8649 :call settabwinvar(3, 2, "myvar", "foobar")
8630 < This function is not available in the |sandbox|. 8650 < This function is not available in the |sandbox|.
8631 8651
8652 Can also be used as a |method|, the base is used as the value: >
8653 GetValue()->settabvar(tab, winnr, name)
8654
8632 settagstack({nr}, {dict} [, {action}]) *settagstack()* 8655 settagstack({nr}, {dict} [, {action}]) *settagstack()*
8633 Modify the tag stack of the window {nr} using {dict}. 8656 Modify the tag stack of the window {nr} using {dict}.
8634 {nr} can be the window number or the |window-ID|. 8657 {nr} can be the window number or the |window-ID|.
8635 8658
8636 For a list of supported items in {dict}, refer to 8659 For a list of supported items in {dict}, refer to
8658 let stack = gettagstack(1003) 8681 let stack = gettagstack(1003)
8659 " do something else 8682 " do something else
8660 call settagstack(1003, stack) 8683 call settagstack(1003, stack)
8661 unlet stack 8684 unlet stack
8662 < 8685 <
8663 setwinvar({nr}, {varname}, {val}) *setwinvar()* 8686 Can also be used as a |method|, the base is used as the Dict: >
8687 GetStack()->settagstack(winnr)
8688
8689 setwinvar({winnr}, {varname}, {val}) *setwinvar()*
8664 Like |settabwinvar()| for the current tab page. 8690 Like |settabwinvar()| for the current tab page.
8665 Examples: > 8691 Examples: >
8666 :call setwinvar(1, "&list", 0) 8692 :call setwinvar(1, "&list", 0)
8667 :call setwinvar(2, "myvar", "foobar") 8693 :call setwinvar(2, "myvar", "foobar")
8668 8694
8695 < Can also be used as a |method|, the base is used as the value: >
8696 GetValue()->setwinvar(winnr, name)
8697
8669 sha256({string}) *sha256()* 8698 sha256({string}) *sha256()*
8670 Returns a String with 64 hex characters, which is the SHA256 8699 Returns a String with 64 hex characters, which is the SHA256
8671 checksum of {string}. 8700 checksum of {string}.
8672 {only available when compiled with the |+cryptv| feature} 8701
8702 Can also be used as a |method|: >
8703 GetText()->sha256()
8704
8705 < {only available when compiled with the |+cryptv| feature}
8673 8706
8674 shellescape({string} [, {special}]) *shellescape()* 8707 shellescape({string} [, {special}]) *shellescape()*
8675 Escape {string} for use as a shell command argument. 8708 Escape {string} for use as a shell command argument.
8676 On MS-Windows, when 'shellslash' is not set, it will enclose 8709 On MS-Windows, when 'shellslash' is not set, it will enclose
8677 {string} in double quotes and double all double quotes within 8710 {string} in double quotes and double all double quotes within
8699 < This results in a directory listing for the file under the 8732 < This results in a directory listing for the file under the
8700 cursor. Example of use with |system()|: > 8733 cursor. Example of use with |system()|: >
8701 :call system("chmod +w -- " . shellescape(expand("%"))) 8734 :call system("chmod +w -- " . shellescape(expand("%")))
8702 < See also |::S|. 8735 < See also |::S|.
8703 8736
8737 Can also be used as a |method|: >
8738 GetCommand()->shellescape()
8704 8739
8705 shiftwidth([{col}]) *shiftwidth()* 8740 shiftwidth([{col}]) *shiftwidth()*
8706 Returns the effective value of 'shiftwidth'. This is the 8741 Returns the effective value of 'shiftwidth'. This is the
8707 'shiftwidth' value unless it is zero, in which case it is the 8742 'shiftwidth' value unless it is zero, in which case it is the
8708 'tabstop' value. This function was introduced with patch 8743 'tabstop' value. This function was introduced with patch
8711 8746
8712 When there is one argument {col} this is used as column number 8747 When there is one argument {col} this is used as column number
8713 for which to return the 'shiftwidth' value. This matters for the 8748 for which to return the 'shiftwidth' value. This matters for the
8714 'vartabstop' feature. If the 'vartabstop' setting is enabled and 8749 'vartabstop' feature. If the 'vartabstop' setting is enabled and
8715 no {col} argument is given, column 1 will be assumed. 8750 no {col} argument is given, column 1 will be assumed.
8751
8752 Can also be used as a |method|: >
8753 GetColumn()->shiftwidth()
8716 8754
8717 sign_ functions are documented here: |sign-functions-details| 8755 sign_ functions are documented here: |sign-functions-details|
8718 8756
8719 8757
8720 simplify({filename}) *simplify()* 8758 simplify({filename}) *simplify()*