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 ...
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.
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 ...
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 ...
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 ...
4
votes
Accepted
How to get vertical wild menu using wildoptions=pum on Vim 9?
vim -Nu NONE
:set wildmenu wildoptions=pum
:e <tab>
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 ...
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
...
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 ...
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 ...
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 ...
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....
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.
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.
2
votes
Accepted
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 ...
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. ...
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 ...
2
votes
Accepted
Start Vim window at a certain size?
I would use:
if has('gui_running')
set columns=80
set lines=20
endif
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 ...
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 ...
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 ...
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>...
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 ':'...
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 ...
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:...
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 ...
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-...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
vim9 × 35vim9script × 11
vimscript × 5
gvim × 5
vimrc × 4
syntax-highlighting × 3
functions × 3
terminal × 2
highlight × 2
plugin-system × 2
filetype × 2
key-bindings × 1
neovim × 1
substitute × 1
normal-mode × 1
colorscheme × 1
microsoft-windows × 1
cursor-motions × 1
macvim × 1
quickfix × 1
terminal-buffer × 1
options × 1
vimscript-python × 1
bash × 1
variables × 1