Yes of course. You'll just need to parse the parameter you receive.
Use the first char as delimiter, and split()
the string with this delimiter. Of course, if you wish to support stuff like :Whatever/st\/uff/other
, it'll be a little bit more complex.
I remember to have given a few answers on SO/vi.SE that implement such command: Here, here, and here.
For instance, in lh-style I have the following:
command! -nargs=1 -range -complete=custom,s:CompleteConvertNames
\ ConvertNames <line1>,<line2>call s:ConvertNames(<f-args>)
" Function: s:ConvertNames(repl_arg) {{{3
" Syntax: ConvertNames/{regex}/{convertion_type}
function! s:ConvertNames(repl_arg) range abort
let sep = a:repl_arg[0]
let fields = split(a:repl_arg, sep)
if len(fields) != 2 && len(fields) != 3
throw ":NameConvert/{regex}/{convertion_type}/[{opt}] expects exactly two or three parameters"
endif
let convertion_type = fields[1]
let i = lh#list#find_if(s:k_convertions, 'v:1_[0]=='.string(convertion_type))
if i == -1
throw "convertion (".convertion_type.") not found"
endif
" build the action to execute
let ConvertFunc = function(s:k_convertions[i][1])
let action = '\=(ConvertFunc(submatch(0)))'
let cmd = a:firstline . ',' . a:lastline . 's'
\. sep . fields[0]
\. sep . action
\. sep.(len(fields)>=3 ? fields[2] : '')
" echomsg cmd
exe cmd
endfunction
EDIT: Here is another (untested) example:
command! -nargs=1
\ Hello call s:Hello(<f-args>)
function! s:ConvertNames(repl_arg) range abort
let sep = a:repl_arg[0]
let fields = split(a:repl_arg, sep)
let cmd = 'echo "Hello".'.string(join(fields, ',')))
exe cmd
endfunction