comparison runtime/doc/vim9.txt @ 21093:99a602b27e0e

Runtime file updates Commit: https://github.com/vim/vim/commit/e46a4405056276b4cbdacee76b11f85c8ea1830b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 30 20:38:27 2020 +0200 Runtime file updates
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Jun 2020 20:45:06 +0200
parents bb49b5090a9c
children 21fb2a3ad3ca
comparison
equal deleted inserted replaced
21092:f49405905ef6 21093:99a602b27e0e
1 *vim9.txt* For Vim version 8.2. Last change: 2020 Jun 22 1 *vim9.txt* For Vim version 8.2. Last change: 2020 Jun 24
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
375 'hello ' .. 123 == 'hello 123' 375 'hello ' .. 123 == 'hello 123'
376 'hello ' .. v:true == 'hello true' 376 'hello ' .. v:true == 'hello true'
377 377
378 In Vim9 script one can use "true" for v:true and "false" for v:false. 378 In Vim9 script one can use "true" for v:true and "false" for v:false.
379 379
380
381 What to watch out for ~
382 *vim9-gotchas*
383 Vim9 was designed to be closer to often used programming languages, but at the
384 same time tries to support the legacy Vim commands. Some compromises had to
385 be made. Here is a summary of what might be unexpected.
386
387 Ex command ranges need to be prefixed with a colon. >
388 -> " legacy Vim: shifts the previous line to the right
389 ->func() " Vim9: method call
390 :-> " Vim9: shifts the previous line to the right
391
392 %s/a/b " legacy Vim: substitute on all lines
393 x = alongname
394 % another " Vim9: line continuation without a backslash
395 :%s/a/b " Vim9: substitute on all lines
396
397 Functions defined with `:def` compile the whole function. Legacy functions
398 can bail out, and the following lines are not parsed: >
399 func Maybe()
400 if !has('feature')
401 return
402 endif
403 use-feature
404 endfunc
405 Vim9 functions are compiled as a whole: >
406 def Maybe()
407 if !has('feature')
408 return
409 endif
410 use-feature " May give compilation error
411 enddef
412 For a workaround, split it in two functions: >
413 func Maybe()
414 if has('feature')
415 call MaybyInner()
416 endif
417 endfunc
418 if has('feature')
419 def MaybeInner()
420 use-feature
421 enddef
422 endif
380 423
381 ============================================================================== 424 ==============================================================================
382 425
383 3. New style functions *fast-functions* 426 3. New style functions *fast-functions*
384 427