vim9script process a range with a function

97 visualizações
Pular para a primeira mensagem não lida

Maxim Kim

não lida,
11 de jan. de 2022, 09:48:4011/01/2022
para vim_use
How in vim9script a range should be processed by a def function?

Vim9.txt states that def functions do not support range option.

So given a range what def function would/should do? Run it for every line in range?

How do I get smth similar to a:firstline and a:lastline?

Bram Moolenaar

não lida,
11 de jan. de 2022, 13:15:0411/01/2022
para vim...@googlegroups.com, Maxim Kim

> How in vim9script a range should be processed by a def function?
>
> Vim9.txt states that def functions do not support range option.
>
> So given a range what def function would/should do? Run it for every line
> in range?

Normally the function will be called for each line in the range.

> How do I get smth similar to a:firstline and a:lastline?

You can pass a range as an argument. Or use marks.

Thus you can't do "1,10call Func()" and have the function called once
for the range. You can define a user command that takes the range and
passes it to the function.

You could also use a legacy function with the range option that calls
the :def function with a:firstline and a:lastine.

--
Facepalm statement #4: "3000 year old graves? That's not possible, it's only
2014!"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem