Skip to main content
Planned maintenance impacting Stack Overflow and all Stack Exchange sites is scheduled for Monday, September 16, 2024, 5:00 PM-10:00 PM EDT (Monday, September 16, 21:00 UTC- Tuesday, September 17, 2:00 UTC). The email/password authentication method will be unavailable for logging in and registering. Read more here
7 votes
Accepted

Vim9: How will '#' characters be handled in colors/* files now?

In vim9 comment starts with either space+# or beginning of the line and # (as far as I remember). So your color setting would still work. :h vim9 /Comments starting<CR> To improve readability ...
Maxim Kim's user avatar
  • 13.8k
6 votes
Accepted

Syntax highlighting for shell scripts broken

It is a known bug which is fixed in the author's source code, see author's reply. It should appear sometime in the future in main vim runtime.
Maxim Kim's user avatar
  • 13.8k
6 votes
Accepted

How can I convert vim8 function mapping to vim9?

I would go with :h vim9-differences before converting legacy to vim9 script. In your def function: remove last : string in def as function returns nothing let should be replaced with var a:command ...
Maxim Kim's user avatar
  • 13.8k
5 votes
Accepted

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

In general you have to declare the variable once using var vim9script var fortran_free_source = 1 is the equivalent of: let s:fortran_free_source=1 After the variable has been declared you can ...
Vivian De Smedt's user avatar
5 votes
Accepted

How to unlet a variable in Vim 9 script?

Global variables are still the same as in legacy script, so unlet works as before. The only difference is that the prefix g: now is always required to access global variables. Unletting non-existent ...
Matt's user avatar
  • 21.3k
4 votes
Accepted

How to get vertical wild menu using wildoptions=pum on Vim 9?

vim -Nu NONE :set wildmenu wildoptions=pum :e <tab>
Maxim Kim's user avatar
  • 13.8k
4 votes
Accepted

How can I enable .xml syntax highlighting for .xaml files?

Assuming all works as you wish it when you enter :set filetype=xml when your XAML file is open in a buffer, try this: create file ~/.vim/ftdetect/xaml.vim containing the following: " Detects XAML ...
MDeBusk's user avatar
  • 461
4 votes

Why doesn't Vim recognize a pair of <\> as a single unit?

I have noticed that regression, too, which seems to affect all text objects with single character boundaries: i< i" i' i{ etc. You should report it if it hasn't been reported already. EDIT ...
romainl's user avatar
  • 41.8k
3 votes

How can I avoid built-in filetype detection?

The *.k extension is detected by $VIMRUNTIME/filetype.vim that comes before the ~/.vim/ftdetect/*.vim in the execution list. That is why you have these scripts being evaluated (kwd.vim calling cpp.vim ...
Vivian De Smedt's user avatar
3 votes

Using Github Copilot with Regular Vim

Inline suggestions (AKA "virtual text" or "ghost text") require vim version 9.0.0162 (patch 162); use vim --version to see vim's version and installed patches, ex.: VIM - Vi ...
kjones's user avatar
  • 153
3 votes

Switch focus to :terminal buffer

I might misunderstand the question, but you can simply switch to a particular window using the normal window-move commands. So if your terminal is in the second window (starting from top to bottom and ...
Christian Brabandt's user avatar
3 votes

Recommended way of scripting: Ex commands or vimscript functions?

As with any topic of sufficient complexity, the answer depends a lot on the context. Unfortunately, "when scripting" is a highly ambiguous statement which led to a lengthy discussion on meta....
Friedrich's user avatar
  • 2,815
2 votes

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

This is because the commandline runs :legacy-mode by default unless :vim9cmd is used.
dza's user avatar
  • 231
2 votes
Accepted

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

For environment variable you can use within Vim the Unix syntax: :echo $foo let $foo = 'bar' For the path I believe you can also use the Unix syntax (/ separated path) for all the Vim API.
Vivian De Smedt's user avatar
2 votes
Accepted

How to change the internal vim python sys.path?

I would do: :py sys.path.append('new_path')
Vivian De Smedt's user avatar
2 votes

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

For the sake of completeness and as requested by a user, here is the solution that I am currently using (based on a user comment): vim9script def QuitWindow() # Close window and wipe buffer but ...
Barzi2001's user avatar
  • 760
2 votes
Accepted

How can I avoid built-in filetype detection?

After a lot of trial and error, I found a solution. It turns out that the order of entries in runtimepath doesn't matter. All I had to do was use au! instead of au in the plugin's ftdetect/k.vim. ...
ngn's user avatar
  • 163
2 votes

How can I avoid built-in filetype detection?

You don't generally need to suppress the filetype detection, because (proper) filetype plugins set b:undo_ftplugin and other variables, which Vim uses automatically to "undo" the results of ...
D. Ben Knoble's user avatar
  • 27.3k
2 votes
Accepted

Start Vim window at a certain size?

I would use: if has('gui_running') set columns=80 set lines=20 endif
Vivian De Smedt's user avatar
1 vote

Using the return of a user defined function in an :execute statement

I'd use CTRL-R= directly here. Also, it seems like you're trying to emulate expand('%:p:h') nnoremap <silent> <F5> :<c-u>!echo <c-r>=expand('%:p:h')<cr><cr> (I'm ...
Luc Hermitte's user avatar
  • 17.7k
1 vote
Accepted

How to noremap plugin functions that take arguments?

The point of <Plug>MyFunc (even better, <Plug>(MyFunc)) is to expose a ready-made "virtual mapping" that can then be remapped at will… without forcing a default mapping onto the ...
romainl's user avatar
  • 41.8k
1 vote

How to noremap plugin functions that take arguments?

I believe there are no way. My understanding of <Plug>(Key) is that it introduces a new virtual Key in your keyboard that you can used in mappings. But these virtual keys have no parameters. If ...
Vivian De Smedt's user avatar
1 vote

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

I would do: vim9script def g:QuitWindow() # Close window and wipe buffer but prevent Vim to quit if one window is # left. if winnr('$') != 1 quit endif enddef nnoremap <c-w>...
Vivian De Smedt's user avatar
1 vote

Switch focus to :terminal buffer

Building on the previous answers I would do: function! TerminalFocus() let l:term_bufs = term_list() if len(term_bufs) > 0 && len(win_findbuf(term_bufs[0])) > 0 return ':'...
hilbor's user avatar
  • 15
1 vote
Accepted

Switch focus to :terminal buffer

I would do: function! MoveFocusToTerminal() let loop = 0 let term_buffers = term_list() while 1 let loop = loop + 1 let bufnr = bufnr('%') if loop > 10 " Don't search ...
Vivian De Smedt's user avatar
1 vote
Accepted

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

To use the vim9 script syntax your script must include as the first command vim9script. vim9script var a = 1 On the command line to run vim9 script command you have to prefix them with :vim9 :vim9 g:...
Vivian De Smedt's user avatar
1 vote
Accepted

How can I control the color of my Vim terminal?

:terminal output colors in Vim are set by :h g:terminal_ansi_colors variable (array of colors) and :h hl-Terminal color. If it doesn't match your colorscheme then either a) the colorscheme has never ...
Matt's user avatar
  • 21.3k
1 vote
Accepted

Some Normal mode mappings not working in vim9 anymore

I believe Vim is not precise in the mapping, in particular you have to specify the key modifier and the resulting character. I believe you should do with Vim-9: nnoremap <S-°> iii nnoremap <S-...
Vivian De Smedt's user avatar
1 vote
Accepted

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

The function created by "def" is script-local by default. On the other hand, the function created by "function" is global by default. The 'quickfixtextfunc' option should be set ...
Yegappan Lakshmanan's user avatar
1 vote
Accepted

Gvim Python loading issue (despite being correctly installed)

Vim needs to find the python310.dll. Like all executable it will search in a number of folders (the list and the order depends on the version of Windows). But the list always includes: The directory ...
Vivian De Smedt's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible