Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [vim9script]

A new, compiled, and experimental version of the scripting language embedded into Vim.

Filter by
Sorted by
Tagged with
0 votes
1 answer
50 views

Vim9script autoloading script results in undefined variable

I'm new to vim9script and taking reference from this section of the vim9 help file. However I keep on getting this error upon calling TermOpen: E121: Undefined variable: util autoload/util.vim: " ...
expoodo's user avatar
  • 11
0 votes
2 answers
76 views

How to use prettier for formatting markdown files on save?

I am wondering what could be an efficient way to achieve what I asked in the title. The best I came out with is the following defined in ~/.vim/ftplugin/markdown.vim: augroup PRETTIER autocmd! * &...
Barzi2001's user avatar
  • 606
0 votes
4 answers
100 views

How can I camel-case extant lowercase text?

I use vim for coding. I have a disability where some of my fingers hurt and I have trouble holding down shift and a letter to produce uppercase. The same goes for parentheses. How can I convert ...
Joselin Jocklingson's user avatar
1 vote
1 answer
51 views

Vim9 lambda function destructuring a list in arguments?

I tried to destructure a list in a lambda function, like this: var matched = reduce( mapnew(lines, (_, x) => [strpart(x, 0, 1), strpart(x, 2, 1)]), (acc, [a, b]) => acc && a == &...
Anopt's user avatar
  • 11
-1 votes
2 answers
76 views

Prevent <c-w>q to quit Vim when there is only one window left

I wish to close windows and wipe out the associated buffers with <c-w>q but at the same time I want to prevent to quit Vim when there is only one window left. My attempt is as follows: ...
Barzi2001's user avatar
  • 606
1 vote
1 answer
49 views

Is there any way to automatically adjust OS specific environment variables, path, etc. format?

Often in my scripts I have some ugly snippets like the following: vim9script var bin = "" if has("win32") bin = "\\bin" else bin = "/bin" endif g:...
Barzi2001's user avatar
  • 606
1 vote
2 answers
206 views

How to automatically close all the terminal buffers when closing vim with :qa?

I am wondering if there is a way to automatically force-wipe all the running terminals when quitting Vim with :qa. My attempt (that does not work): vim9script def WipeoutTerminals() for buf_nr in ...
Barzi2001's user avatar
  • 606
0 votes
2 answers
89 views

How to re-open the same window with the same buffer therein?

Consider the following snippet: vim9script # Set stuff in the newly created window var my_win_nr = winnr('$') var my_win_id = win_getid(my_win_nr) win_execute(my_win_id, 'wincmd L') win_execute(...
Barzi2001's user avatar
  • 606
1 vote
1 answer
172 views

Vim9 vs legacy: are there any benefits in using interpolated strings over .. and in using "new" autoload over the "old" autoload mechanism?

I am wondering if it is just a matter of taste or if there is any benefit in using some of the new features in Vim9. I am interested in interpolated-strings and the autoload mechanism. interpolated-...
Barzi2001's user avatar
  • 606
0 votes
0 answers
72 views

Plugin function scope issue

I have recently discovered this guide that was very eye opener under many aspects. So I decided to do things "by the book" by moving my plugins in ~/.vim/pack/bundle/start/myplugin/plugin/...
Barzi2001's user avatar
  • 606
0 votes
2 answers
90 views

How can I define a buffer-local variable in a FileType autocommand using vim9script?

I am trying to define a buffer variable based on the FileType as it follows: vim9script def g:MyComment(comment_symbol: string) # Do something enddef augroup commenting_blocks_of_code ...
Barzi2001's user avatar
  • 606
5 votes
1 answer
155 views

How to export function conditionally in Vim9script?

I have a plugin which exports a couple of functions. These functions depend on a few script-local functions. I want to test these script-local functions. The best way I can think of to do that, ...
Andy Stewart's user avatar
  • 1,359
0 votes
2 answers
95 views

Vim9script commands from command line result in E1124. Is it normal?

If I run e.g. :var a = 1 from the command line I end up in E1124: "var" cannot be used in legacy vimscript. Running on MacVim 9.0.1276. Is it normal behavior?
Barzi2001's user avatar
  • 606
0 votes
1 answer
87 views

Get the last line of Vim terminal output

I use Vim for editing DocBook files. I created several functions that manipulate the text in the buffer. For example to build a PDF from the source using an external command. I run these functions ...
Tomáš Bažant's user avatar
0 votes
3 answers
97 views

vim9script syntax highlighting range

I want to translate the following functions to vim9script and also combine them into one because they basically do the same function! Hi_Py() let b:current_syntax='' unlet b:current_syntax ...
whoopdedoo's user avatar
0 votes
1 answer
102 views

How can I make 'quickfixtextfunc' work with cfilter using a vim9's "def" function?

On Windows 10, using gvim, when editing a file like the following example: foo foobar baz As long as I use a function and not a def, I can do the following and Cfilter will work as expected: :...
Minh-Tâm TRAN's user avatar
5 votes
1 answer
427 views

How can I convert vim8 function mapping to vim9?

I have a function in vim8 as: function! BSkipQuickFix(command) let start_buffer = bufnr('%') execute a:command while &buftype ==# 'quickfix' && bufnr('%') != start_buffer execute ...
BaRud's user avatar
  • 491
2 votes
1 answer
695 views

How do I :let a global variable in my vimrc in vim9script?

I am trying to change my vimrc to vim9script. For inbuilt fortran help, (:h fortran) we have: :let fortran_free_source=1 This is giving an error: E1126: Cannot use :let in Vim9 script If I remove ...
BaRud's user avatar
  • 491
1 vote
1 answer
531 views

How to unlet a variable in Vim 9 script?

In Vim9 script :let cannot be used. An existing variable is assigned to without any command. The same for global, window, tab, buffer and Vim variables, because they are not really declared. Those ...
user90726's user avatar
  • 123
1 vote
1 answer
611 views

'Undefined variable' error: why?

vim9script set laststatus=2 set statusline= var separator = ' ' set statusline+=%{expand('%:p')} set statusline+=%{separator} set statusline+=%l:%v Error: Undefined variable: separator Why is ...
john c. j.'s user avatar
7 votes
1 answer
1k views

How to learn vimscript along with vim9script?

I've finally made the decision to learn vimscript. I don't hate reading manual and really like the built-in help files, so I am starting with usr_41.txt and plan to read eval.txt afterwards. Now as I ...
Masquue's user avatar
  • 81
5 votes
0 answers
239 views

Issue when moving Vim9script plugin's functions to autoload

I've read :help write-plugin to understand a bit more about how to write a plugin in Vim9script, but there aspects of that that puzzle me. Here's a very simplified, working version of the example ...
Enlico's user avatar
  • 2,214
1 vote
1 answer
122 views

How can I write an out_cb handler in vim9script?

In §9 of :h channel is mentioned the legacy vimscript out_cb handler. let job = job_start(command, {"out_cb": "MyHandler"}) The function will be called with the channel and a ...
N i k o la y T h e B l o o d y's user avatar
2 votes
1 answer
2k views

How can I define vim9 functions and vim9 lambdas in a vim9 script?

In :help vim9 I read The Vim9 script syntax and semantics are used in: a function defined with the :def command a script file where the first command is vim9script an autocommand defined in the ...
Enlico's user avatar
  • 2,214
7 votes
2 answers
2k views

Why is Vim9 mentioned at all in the doc of Vim 8?

Looking for lambda in the doc, I've found out (to my surprise) that they do exist in vimscript, and they use the syntax {args -> expr1}. But I've also discovered that there's Vim9, the doc of which ...
Enlico's user avatar
  • 2,214
2 votes
1 answer
423 views

How do I work with vim9 and unicode?

I've found myself in a bit of an interesting situation. I'm writing a plugin in which I need to do a tiny bit of line parsing. Given a file: æøå It's easy to verify that col('.') returns 1, 3, and 5 ...
Zoe's user avatar
  • 712