comparison runtime/doc/builtin.txt @ 28994:644b0f0541de v8.2.5019

patch 8.2.5019: cannot get the first screen column of a character Commit: https://github.com/vim/vim/commit/0f7a3e1de6f71e8e1423fe594890d6aa7f94e132 Author: LemonBoy <thatlemon@gmail.com> Date: Thu May 26 12:10:37 2022 +0100 patch 8.2.5019: cannot get the first screen column of a character Problem: Cannot get the first screen column of a character. Solution: Let virtcol() optionally return a list. (closes https://github.com/vim/vim/issues/10482, closes #7964)
author Bram Moolenaar <Bram@vim.org>
date Thu, 26 May 2022 13:15:04 +0200
parents 3c3bdb8069f5
children aadeddf38d9b
comparison
equal deleted inserted replaced
28993:05930f3364a2 28994:644b0f0541de
687 undofile({name}) String undo file name for {name} 687 undofile({name}) String undo file name for {name}
688 undotree() List undo file tree 688 undotree() List undo file tree
689 uniq({list} [, {func} [, {dict}]]) 689 uniq({list} [, {func} [, {dict}]])
690 List remove adjacent duplicates from a list 690 List remove adjacent duplicates from a list
691 values({dict}) List values in {dict} 691 values({dict}) List values in {dict}
692 virtcol({expr}) Number screen column of cursor or mark 692 virtcol({expr} [, {list}]) Number or List
693 screen column of cursor or mark
693 visualmode([expr]) String last visual mode used 694 visualmode([expr]) String last visual mode used
694 wildmenumode() Number whether 'wildmenu' mode is active 695 wildmenumode() Number whether 'wildmenu' mode is active
695 win_execute({id}, {command} [, {silent}]) 696 win_execute({id}, {command} [, {silent}])
696 String execute {command} in window {id} 697 String execute {command} in window {id}
697 win_findbuf({bufnr}) List find windows containing {bufnr} 698 win_findbuf({bufnr}) List find windows containing {bufnr}
778 779
779 780
780 and({expr}, {expr}) *and()* 781 and({expr}, {expr}) *and()*
781 Bitwise AND on the two arguments. The arguments are converted 782 Bitwise AND on the two arguments. The arguments are converted
782 to a number. A List, Dict or Float argument causes an error. 783 to a number. A List, Dict or Float argument causes an error.
784 Also see `or()` and `xor()`.
783 Example: > 785 Example: >
784 :let flag = and(bits, 0x80) 786 :let flag = and(bits, 0x80)
785 < Can also be used as a |method|: > 787 < Can also be used as a |method|: >
786 :let flag = bits->and(0x80) 788 :let flag = bits->and(0x80)
787 789
934 bufnr buffer number to add a buffer-local autocmd. 936 bufnr buffer number to add a buffer-local autocmd.
935 If this item is specified, then the "pattern" 937 If this item is specified, then the "pattern"
936 item is ignored. 938 item is ignored.
937 cmd Ex command to execute for this autocmd event 939 cmd Ex command to execute for this autocmd event
938 event autocmd event name. Refer to |autocmd-events|. 940 event autocmd event name. Refer to |autocmd-events|.
941 TODO: currently only accepts one event.
939 group autocmd group name. Refer to |autocmd-groups|. 942 group autocmd group name. Refer to |autocmd-groups|.
940 If this group doesn't exist then it is 943 If this group doesn't exist then it is
941 created. If not specified or empty, then the 944 created. If not specified or empty, then the
942 default group is used. 945 default group is used.
943 nested boolean flag, set to v:true to add a nested 946 nested boolean flag, set to v:true to add a nested
944 autocmd. Refer to |autocmd-nested|. 947 autocmd. Refer to |autocmd-nested|.
945 once boolean flag, set to v:true to add a autocmd 948 once boolean flag, set to v:true to add an autocmd
946 which executes only once. Refer to 949 which executes only once. Refer to
947 |autocmd-once|. 950 |autocmd-once|.
948 pattern autocmd pattern string. Refer to 951 pattern autocmd pattern string. Refer to
949 |autocmd-patterns|. If "bufnr" item is 952 |autocmd-patterns|. If "bufnr" item is
950 present, then this item is ignored. 953 present, then this item is ignored.
951 replace boolean flag, set to v:true to remove all the 954 replace boolean flag, set to v:true to remove all the
952 commands associated with the specified autocmd 955 commands associated with the specified autocmd
953 event and group and add the {cmd}. This is 956 event and group and add the {cmd}. This is
954 useful to avoid adding the same command 957 useful to avoid adding the same command
955 multiple times for a autocmd event in a group. 958 multiple times for an autocmd event in a group.
956 959
957 Returns v:true on success and v:false on failure. 960 Returns v:true on success and v:false on failure.
958 Examples: > 961 Examples: >
959 " Create a buffer-local autocmd for buffer 5 962 " Create a buffer-local autocmd for buffer 5
960 let acmd = {} 963 let acmd = {}
9725 in arbitrary order. Also see |items()| and |keys()|. 9728 in arbitrary order. Also see |items()| and |keys()|.
9726 9729
9727 Can also be used as a |method|: > 9730 Can also be used as a |method|: >
9728 mydict->values() 9731 mydict->values()
9729 9732
9730 virtcol({expr}) *virtcol()* 9733 virtcol({expr} [, {list}]) *virtcol()*
9731 The result is a Number, which is the screen column of the file 9734 The result is a Number, which is the screen column of the file
9732 position given with {expr}. That is, the last screen position 9735 position given with {expr}. That is, the last screen position
9733 occupied by the character at that position, when the screen 9736 occupied by the character at that position, when the screen
9734 would be of unlimited width. When there is a <Tab> at the 9737 would be of unlimited width. When there is a <Tab> at the
9735 position, the returned Number will be the column at the end of 9738 position, the returned Number will be the column at the end of
9736 the <Tab>. For example, for a <Tab> in column 1, with 'ts' 9739 the <Tab>. For example, for a <Tab> in column 1, with 'ts'
9737 set to 8, it returns 8. |conceal| is ignored. 9740 set to 8, it returns 8. |conceal| is ignored.
9738 For the byte position use |col()|. 9741 For the byte position use |col()|.
9742
9739 For the use of {expr} see |col()|. 9743 For the use of {expr} see |col()|.
9740 When 'virtualedit' is used {expr} can be [lnum, col, off], where 9744
9741 "off" is the offset in screen columns from the start of the 9745 When 'virtualedit' is used {expr} can be [lnum, col, off],
9742 character. E.g., a position within a <Tab> or after the last 9746 where "off" is the offset in screen columns from the start of
9743 character. When "off" is omitted zero is used. 9747 the character. E.g., a position within a <Tab> or after the
9744 When Virtual editing is active in the current mode, a position 9748 last character. When "off" is omitted zero is used. When
9745 beyond the end of the line can be returned. |'virtualedit'| 9749 Virtual editing is active in the current mode, a position
9750 beyond the end of the line can be returned. Also see
9751 |'virtualedit'|
9752
9746 The accepted positions are: 9753 The accepted positions are:
9747 . the cursor position 9754 . the cursor position
9748 $ the end of the cursor line (the result is the 9755 $ the end of the cursor line (the result is the
9749 number of displayed characters in the cursor line 9756 number of displayed characters in the cursor line
9750 plus one) 9757 plus one)
9752 returned) 9759 returned)
9753 v In Visual mode: the start of the Visual area (the 9760 v In Visual mode: the start of the Visual area (the
9754 cursor is the end). When not in Visual mode 9761 cursor is the end). When not in Visual mode
9755 returns the cursor position. Differs from |'<| in 9762 returns the cursor position. Differs from |'<| in
9756 that it's updated right away. 9763 that it's updated right away.
9764
9765 If {list} is present and non-zero then virtcol() returns a List
9766 with the first and last screen position occupied by the
9767 character.
9768
9757 Note that only marks in the current file can be used. 9769 Note that only marks in the current file can be used.
9758 Examples: > 9770 Examples: >
9759 virtcol(".") with text "foo^Lbar", with cursor on the "^L", returns 5 9771 " With text "foo^Lbar" and cursor on the "^L":
9760 virtcol("$") with text "foo^Lbar", returns 9 9772
9761 virtcol("'t") with text " there", with 't at 'h', returns 6 9773 virtcol(".") " returns 5
9774 virtcol(".", 1) " returns [4, 5]
9775 virtcol("$") " returns 9
9776
9777 " With text " there", with 't at 'h':
9778
9779 virtcol("'t") " returns 6
9762 < The first column is 1. 0 is returned for an error. 9780 < The first column is 1. 0 is returned for an error.
9763 A more advanced example that echoes the maximum length of 9781 A more advanced example that echoes the maximum length of
9764 all lines: > 9782 all lines: >
9765 echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) 9783 echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
9766 9784