Search code examples
vimvim-plugin

"E119: Not enough arguments" error with -nargs=+


These are my commands and functions that get name and address for app or url to launch em withing vim. They store the value in .txt files. Problem is that both commands give me "E119: Not enough arguments for function: Adda/Addw"

command! -nargs=+ Addw call Addw(<q-args>)
command! -nargs=+ Adda call Adda(<q-args>)

function! Addw(name, address)
 let web_addresses_file = expand('~/vimfiles/plugged/flexibleVP/data/webaddress.txt')
  let web_addresses = readfile(web_addresses_file)
  let new_line = a:name . ': ' . a:address

  call writefile(web_addresses + [new_line], web_addresses_file)
  echo 'Web address added: ' . new_line
endfunction

function! Adda(name, address)
let app_addresses_file = expand('~/vimfiles/plugged/flexibleVP/data/appaddress.txt')
  let app_addresses = readfile(app_addresses_file)
  let new_line = a:name . ': ' . a:address

  call writefile(app_addresses + [new_line], app_addresses_file)
  echo 'App address added: ' . new_line
endfunction

Tried with l:name and l:address; Tried -nargs=*


Solution

  • just used f-args instead of q-args