5

I have a function in vim8 as:

function! BSkipQuickFix(command)
  let start_buffer = bufnr('%')
  execute a:command
  while &buftype ==# 'quickfix' && bufnr('%') != start_buffer
    execute a:command
  endwhile
endfunction

nnoremap <F12> :call BSkipQuickFix("bn")<CR>
nnoremap <S-F12> :call BSkipQuickFix("bp")<CR>

which I have converted to vim9 as:

def BSkipQuickFix(command: string): string
  let start_buffer = bufnr('%')
  execute a:command
  while &buftype ==# 'quickfix' && bufnr('%') != start_buffer
    execute a:command
  endwhile
enddef

nnoremap <F12> : BSkipQuickFix("bn")<CR>
nnoremap <S-F12> : BSkipQuickFix("bp")<CR>

Now, I am getting E117: Unknown function: BSkipQuickFix. Any help please?

1
  • 1
    You did not convert it, so the function is not compiled and you can't use it, because it is unknown.
    – Maxim Kim
    Sep 7, 2022 at 8:07

1 Answer 1

6

I would go with :h vim9-differences before converting legacy to vim9 script.

In your def function:

  1. remove last : string in def as function returns nothing
  2. let should be replaced with var
  3. a:command should be replaced with command
  4. nnoremap should use <scriptcmd>BSkipQuickFix("bn")<CR> without :
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.