comparison runtime/doc/eval.txt @ 5413:3109053ce4e3 v7.4.057

updated for version 7.4.057 Problem: byteidx() does not work for composing characters. Solution: Add byteidxcomp().
author Bram Moolenaar <bram@vim.org>
date Sat, 02 Nov 2013 23:29:26 +0100
parents 22da5ab9aaa1
children 9521463d4fc1
comparison
equal deleted inserted replaced
5412:5126b80647a2 5413:3109053ce4e3
1711 bufname( {expr}) String Name of the buffer {expr} 1711 bufname( {expr}) String Name of the buffer {expr}
1712 bufnr( {expr}) Number Number of the buffer {expr} 1712 bufnr( {expr}) Number Number of the buffer {expr}
1713 bufwinnr( {expr}) Number window number of buffer {expr} 1713 bufwinnr( {expr}) Number window number of buffer {expr}
1714 byte2line( {byte}) Number line number at byte count {byte} 1714 byte2line( {byte}) Number line number at byte count {byte}
1715 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} 1715 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
1716 byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
1716 call( {func}, {arglist} [, {dict}]) 1717 call( {func}, {arglist} [, {dict}])
1717 any call {func} with arguments {arglist} 1718 any call {func} with arguments {arglist}
1718 ceil( {expr}) Float round {expr} up 1719 ceil( {expr}) Float round {expr} up
1719 changenr() Number current change number 1720 changenr() Number current change number
1720 char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr} 1721 char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
2259 byteidx({expr}, {nr}) *byteidx()* 2260 byteidx({expr}, {nr}) *byteidx()*
2260 Return byte index of the {nr}'th character in the string 2261 Return byte index of the {nr}'th character in the string
2261 {expr}. Use zero for the first character, it returns zero. 2262 {expr}. Use zero for the first character, it returns zero.
2262 This function is only useful when there are multibyte 2263 This function is only useful when there are multibyte
2263 characters, otherwise the returned value is equal to {nr}. 2264 characters, otherwise the returned value is equal to {nr}.
2264 Composing characters are counted as a separate character. 2265 Composing characters are not counted separately, their byte
2266 length is added to the preceding base character. See
2267 |byteidxcomp()| below for counting composing characters
2268 separately.
2265 Example : > 2269 Example : >
2266 echo matchstr(str, ".", byteidx(str, 3)) 2270 echo matchstr(str, ".", byteidx(str, 3))
2267 < will display the fourth character. Another way to do the 2271 < will display the fourth character. Another way to do the
2268 same: > 2272 same: >
2269 let s = strpart(str, byteidx(str, 3)) 2273 let s = strpart(str, byteidx(str, 3))
2270 echo strpart(s, 0, byteidx(s, 1)) 2274 echo strpart(s, 0, byteidx(s, 1))
2271 < If there are less than {nr} characters -1 is returned. 2275 < If there are less than {nr} characters -1 is returned.
2272 If there are exactly {nr} characters the length of the string 2276 If there are exactly {nr} characters the length of the string
2273 is returned. 2277 in bytes is returned.
2278
2279 byteidxcomp({expr}, {nr}) *byteidxcomp()*
2280 Like byteidx(), except that a composing character is counted
2281 as a separate character. Example: >
2282 let s = 'e' . nr2char(0x301)
2283 echo byteidx(s, 1)
2284 echo byteidxcomp(s, 1)
2285 echo byteidxcomp(s, 2)
2286 < The first and third echo result in 3 ('e' plus composing
2287 character is 3 bytes), the second echo results in 1 ('e' is
2288 one byte).
2289 Only works different from byteidx() when 'encoding' is set to
2290 a Unicode encoding.
2274 2291
2275 call({func}, {arglist} [, {dict}]) *call()* *E699* 2292 call({func}, {arglist} [, {dict}]) *call()* *E699*
2276 Call function {func} with the items in |List| {arglist} as 2293 Call function {func} with the items in |List| {arglist} as
2277 arguments. 2294 arguments.
2278 {func} can either be a |Funcref| or the name of a function. 2295 {func} can either be a |Funcref| or the name of a function.