vim9: Error when using setbufline() as a method

11 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Dec 24, 2020, 2:18:36 PM12/24/20
to vim_dev
Hi,

The following vim9 script generates a E1030 error:
============================================
vim9script
var bnr = bufnr()
bnr->setbufline(1, "Hello")
============================================

The following fragment works properly:
============================================
vim9script
var bnr = bufnr()
setbufline(bnr, 1, "Hello")
============================================

Regards,
Yegappan


Bram Moolenaar

unread,
Dec 25, 2020, 7:54:31 AM12/25/20
to vim...@googlegroups.com, Yegappan Lakshmanan
The base is passed as the third argument, the text. This works:

"Hello"->setbufline(bnr, 1)

The idea is that you somehow generate the text with a series of function
calls, then store it in a buffer line.

--
How To Keep A Healthy Level Of Insanity:
1. At lunch time, sit in your parked car with sunglasses on and point
a hair dryer at passing cars. See if they slow down.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Dec 25, 2020, 10:40:56 AM12/25/20
to Bram Moolenaar, vim_dev
Hi Bram,

On Fri, Dec 25, 2020 at 4:54 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Yegappan wrote:

> The following vim9 script generates a E1030 error:
> ============================================
> vim9script
> var bnr = bufnr()
> bnr->setbufline(1, "Hello")
> ============================================
>
> The following fragment works properly:
> ============================================
> vim9script
> var bnr = bufnr()
> setbufline(bnr, 1, "Hello")
> ============================================

The base is passed as the third argument, the text.  This works:

        "Hello"->setbufline(bnr, 1)

The idea is that you somehow generate the text with a series of function
calls, then store it in a buffer line.



Thanks. I somehow missed reading that in the help. As I was using other
buffer functions (getbufline(), setbufvar(), getbufvar(), getbufinfo(), deletebufline(),
bufloaded(), etc.) as methods using the buffer number, I tried that with the
setbufline() function.

Regards,
Yegappan

Reply all
Reply to author
Forward
0 new messages