comparison runtime/doc/vim9.txt @ 20982:bb49b5090a9c v8.2.1042

patch 8.2.1042: Vim9: cannot put an operator on the next line Commit: https://github.com/vim/vim/commit/df069eec3b90401e880e9b0e258146d8f36c474d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 22 23:02:51 2020 +0200 patch 8.2.1042: Vim9: cannot put an operator on the next line Problem: Vim9: cannot put an operator on the next line. Solution: Require a colon before a range to see if that causes problems.
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jun 2020 23:15:04 +0200
parents 59f93c2d2551
children 99a602b27e0e
comparison
equal deleted inserted replaced
20981:6e0166b4443d 20982:bb49b5090a9c
1 *vim9.txt* For Vim version 8.2. Last change: 2020 Jun 21 1 *vim9.txt* For Vim version 8.2. Last change: 2020 Jun 22
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
255 let result = Func( 255 let result = Func(
256 arg1, 256 arg1,
257 arg2 257 arg2
258 ) 258 )
259 259
260 For binary operators iin expressions not in [], {} or () a line break is 260 For binary operators in expressions not in [], {} or () a line break is
261 possible AFTER the operators. For example: > 261 possible just before or after the operator. For example: >
262 let text = lead .. 262 let text = lead
263 middle .. 263 .. middle
264 end 264 .. end
265 let total = start + 265 let total = start +
266 end - 266 end -
267 correction 267 correction
268 let result = positive ? 268 let result = positive
269 PosFunc(arg) : 269 ? PosFunc(arg)
270 NegFunc(arg) 270 : NegFunc(arg)
271 271
272 A special case is "->" for function call chains, it can appear in the next
273 line: >
274 let result = GetBuilder() 272 let result = GetBuilder()
275 ->BuilderSetWidth(333) 273 ->BuilderSetWidth(333)
276 ->BuilderSetHeight(777) 274 ->BuilderSetHeight(777)
277 ->BuilderBuild() 275 ->BuilderBuild()
278 276
279 Note that "enddef" cannot be used at the start of a continuation line, it ends 277 < *E1050*
280 the current function. 278 To make it possible for the operator at the start of the line to be
279 recognized, it is required to put a colon before a range. This will adde
280 "start" and print: >
281 let result = start
282 + print
283 This will assign "start" and print a line: >
284 let result = start
285 :+ print
281 286
282 It is also possible to split a function header over multiple lines, in between 287 It is also possible to split a function header over multiple lines, in between
283 arguments: > 288 arguments: >
284 def MyFunc( 289 def MyFunc(
285 text: string, 290 text: string,
286 separator = '-' 291 separator = '-'
287 ): string 292 ): string
293
294 Note that "enddef" cannot be used at the start of a continuation line, it ends
295 the current function.
288 296
289 297
290 No curly braces expansion ~ 298 No curly braces expansion ~
291 299
292 |curly-braces-names| cannot be used. 300 |curly-braces-names| cannot be used.