Mercurial > vim
diff runtime/doc/vim9.txt @ 24128:fcbb1d4df15b v8.2.2605
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Commit: https://github.com/vim/vim/commit/0289a093a4d65c6280a3be118d1d3696d1aa74da
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 14 18:40:19 2021 +0100
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Problem: Vim9: string index and slice does not include composing chars.
Solution: Include composing characters. (issue https://github.com/vim/vim/issues/6563)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Mar 2021 18:45:03 +0100 |
parents | 788e10cec9bd |
children | 4919f2d8d7fd |
line wrap: on
line diff
--- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -96,8 +96,8 @@ script and `:def` functions; details are def CallMe(count: number, message: string): bool - Call functions without `:call`: > writefile(['done'], 'file.txt') -- You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert` or - curly-braces names. +- You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert`, `:open` + or curly-braces names. - A range before a command must be prefixed with a colon: > :%s/this/that - Unless mentioned specifically, the highest |scriptversion| is used. @@ -341,7 +341,8 @@ Functions can be called without `:call`: Using `:call` is still possible, but this is discouraged. A method call without `eval` is possible, so long as the start is an -identifier or can't be an Ex command. Examples: > +identifier or can't be an Ex command. For a function either "(" or "->" must +be following, without a line break. Examples: > myList->add(123) g:myList->add(123) [1, 2, 3]->Process() @@ -696,8 +697,9 @@ for v:null. When converting a boolean t used, not "v:false" and "v:true" like in legacy script. "v:none" is not changed, it is only used in JSON and has no equivalent in other languages. -Indexing a string with [idx] or [idx : idx] uses character indexes instead of -byte indexes. Example: > +Indexing a string with [idx] or taking a slice with [idx : idx] uses character +indexes instead of byte indexes. Composing characters are included. +Example: > echo 'bár'[1] In legacy script this results in the character 0xc3 (an illegal byte), in Vim9 script this results in the string 'á'. @@ -845,6 +847,8 @@ THIS IS STILL UNDER DEVELOPMENT - ANYTHI :enddef End of a function defined with `:def`. It should be on a line by its own. +You may also find this wiki useful. It was written by an early adoptor of +Vim9 script: https://github.com/lacygoill/wiki/blob/master/vim/vim9.md If the script the function is defined in is Vim9 script, then script-local variables can be accessed without the "s:" prefix. They must be defined