Mercurial > vim
comparison runtime/doc/eval.txt @ 21935:62f933f64447 v8.2.1517
patch 8.2.1517: cannot easily get the character under the cursor
Commit: https://github.com/vim/vim/commit/6c53fca02301ff871cddc1c74c388e23e53a424a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 23 17:34:46 2020 +0200
patch 8.2.1517: cannot easily get the character under the cursor
Problem: Cannot easily get the character under the cursor.
Solution: Add the {chars} argument to strpart().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 23 Aug 2020 17:45:03 +0200 |
parents | fb74a3387694 |
children | 0bc43a704f56 |
comparison
equal
deleted
inserted
replaced
21934:520a6af17d92 | 21935:62f933f64447 |
---|---|
2834 str2list({expr} [, {utf8}]) List convert each character of {expr} to | 2834 str2list({expr} [, {utf8}]) List convert each character of {expr} to |
2835 ASCII/UTF8 value | 2835 ASCII/UTF8 value |
2836 str2nr({expr} [, {base} [, {quoted}]]) | 2836 str2nr({expr} [, {base} [, {quoted}]]) |
2837 Number convert String to Number | 2837 Number convert String to Number |
2838 strcharpart({str}, {start} [, {len}]) | 2838 strcharpart({str}, {start} [, {len}]) |
2839 String {len} characters of {str} at {start} | 2839 String {len} characters of {str} at |
2840 character {start} | |
2840 strchars({expr} [, {skipcc}]) Number character length of the String {expr} | 2841 strchars({expr} [, {skipcc}]) Number character length of the String {expr} |
2841 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} | 2842 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} |
2842 strftime({format} [, {time}]) String format time with a specified format | 2843 strftime({format} [, {time}]) String format time with a specified format |
2843 strgetchar({str}, {index}) Number get char {index} from {str} | 2844 strgetchar({str}, {index}) Number get char {index} from {str} |
2844 stridx({haystack}, {needle} [, {start}]) | 2845 stridx({haystack}, {needle} [, {start}]) |
2845 Number index of {needle} in {haystack} | 2846 Number index of {needle} in {haystack} |
2846 string({expr}) String String representation of {expr} value | 2847 string({expr}) String String representation of {expr} value |
2847 strlen({expr}) Number length of the String {expr} | 2848 strlen({expr}) Number length of the String {expr} |
2848 strpart({str}, {start} [, {len}]) | 2849 strpart({str}, {start} [, {len} [, {chars}]]) |
2849 String {len} bytes of {str} at byte {start} | 2850 String {len} bytes/chars of {str} at |
2851 byte {start} | |
2850 strptime({format}, {timestring}) | 2852 strptime({format}, {timestring}) |
2851 Number Convert {timestring} to unix timestamp | 2853 Number Convert {timestring} to unix timestamp |
2852 strridx({haystack}, {needle} [, {start}]) | 2854 strridx({haystack}, {needle} [, {start}]) |
2853 Number last index of {needle} in {haystack} | 2855 Number last index of {needle} in {haystack} |
2854 strtrans({expr}) String translate string to make it printable | 2856 strtrans({expr}) String translate string to make it printable |
3416 < {not available when compiled without the |+byte_offset| | 3418 < {not available when compiled without the |+byte_offset| |
3417 feature} | 3419 feature} |
3418 | 3420 |
3419 byteidx({expr}, {nr}) *byteidx()* | 3421 byteidx({expr}, {nr}) *byteidx()* |
3420 Return byte index of the {nr}'th character in the string | 3422 Return byte index of the {nr}'th character in the string |
3421 {expr}. Use zero for the first character, it returns zero. | 3423 {expr}. Use zero for the first character, it then returns |
3424 zero. | |
3422 This function is only useful when there are multibyte | 3425 This function is only useful when there are multibyte |
3423 characters, otherwise the returned value is equal to {nr}. | 3426 characters, otherwise the returned value is equal to {nr}. |
3424 Composing characters are not counted separately, their byte | 3427 Composing characters are not counted separately, their byte |
3425 length is added to the preceding base character. See | 3428 length is added to the preceding base character. See |
3426 |byteidxcomp()| below for counting composing characters | 3429 |byteidxcomp()| below for counting composing characters |
9946 *strlen()* | 9949 *strlen()* |
9947 strlen({expr}) The result is a Number, which is the length of the String | 9950 strlen({expr}) The result is a Number, which is the length of the String |
9948 {expr} in bytes. | 9951 {expr} in bytes. |
9949 If the argument is a Number it is first converted to a String. | 9952 If the argument is a Number it is first converted to a String. |
9950 For other types an error is given. | 9953 For other types an error is given. |
9951 If you want to count the number of multi-byte characters use | 9954 If you want to count the number of multibyte characters use |
9952 |strchars()|. | 9955 |strchars()|. |
9953 Also see |len()|, |strdisplaywidth()| and |strwidth()|. | 9956 Also see |len()|, |strdisplaywidth()| and |strwidth()|. |
9954 | 9957 |
9955 Can also be used as a |method|: > | 9958 Can also be used as a |method|: > |
9956 GetString()->strlen() | 9959 GetString()->strlen() |
9957 | 9960 |
9958 strpart({src}, {start} [, {len}]) *strpart()* | 9961 strpart({src}, {start} [, {len} [, {chars}]]) *strpart()* |
9959 The result is a String, which is part of {src}, starting from | 9962 The result is a String, which is part of {src}, starting from |
9960 byte {start}, with the byte length {len}. | 9963 byte {start}, with the byte length {len}. |
9961 To count characters instead of bytes use |strcharpart()|. | 9964 When {chars} is present and TRUE then {len} is the number of |
9965 characters positions (composing characters are not counted | |
9966 separately, thus "1" means one base character and any | |
9967 following composing characters). | |
9968 To count {start} as characters instead of bytes use | |
9969 |strcharpart()|. | |
9962 | 9970 |
9963 When bytes are selected which do not exist, this doesn't | 9971 When bytes are selected which do not exist, this doesn't |
9964 result in an error, the bytes are simply omitted. | 9972 result in an error, the bytes are simply omitted. |
9965 If {len} is missing, the copy continues from {start} till the | 9973 If {len} is missing, the copy continues from {start} till the |
9966 end of the {src}. > | 9974 end of the {src}. > |
9968 strpart("abcdefg", -2, 4) == "ab" | 9976 strpart("abcdefg", -2, 4) == "ab" |
9969 strpart("abcdefg", 5, 4) == "fg" | 9977 strpart("abcdefg", 5, 4) == "fg" |
9970 strpart("abcdefg", 3) == "defg" | 9978 strpart("abcdefg", 3) == "defg" |
9971 | 9979 |
9972 < Note: To get the first character, {start} must be 0. For | 9980 < Note: To get the first character, {start} must be 0. For |
9973 example, to get three bytes under and after the cursor: > | 9981 example, to get the character under the cursor: > |
9974 strpart(getline("."), col(".") - 1, 3) | 9982 strpart(getline("."), col(".") - 1, 1, v:true) |
9975 < | 9983 < |
9976 Can also be used as a |method|: > | 9984 Can also be used as a |method|: > |
9977 GetText()->strpart(5) | 9985 GetText()->strpart(5) |
9978 | 9986 |
9979 strptime({format}, {timestring}) *strptime()* | 9987 strptime({format}, {timestring}) *strptime()* |