1

I'd like a Build command that starts a build independent of what build system is used.

command! -nargs=* Build :Makeshift<Bar>MakeshiftBuild <args>

gives me

E488: Trailing characters

Either one can be mapped and works, but the two of them produce the error. I tried -bar on my map. I cannot change Makeshift to use it.

The following works:

function! s:BuildFun(what2build)
    execute 'Makeshift'
    execute 'MakeshiftBuild '.a:what2build
endfunction
command! -nargs=* Build :call s:BuildFun(<q-args>)

Can someone clarify, why the one-liner does not work or how to make it work. Just to gain insight.

4
  • This works fine for me.
    – muru
    Jun 26 '19 at 10:54
  • johnsyweb/vim-makeshift or do you use a different one? Jun 26 '19 at 11:48
  • 1
    No, I just tested with made-up Makeshift and MakeshiftBuild commands. Now I see the problem. For custom commands to be chainable via |, they need the -bar attribute. Makeshift is not defined with -bar.
    – muru
    Jun 26 '19 at 11:51
  • Thanks. This is solved then. Jun 26 '19 at 13:07
1

The answer is in the comment: Makeshift was defined without a -bar parameter. From vim help command:

-bar        The command can be followed by a "|" and another command.
            A "|" inside the command argument is not allowed then.
            Also checks for a " to start a comment.

In such cases there is no need to fork the plugin repo, because one can use the workaround with the function, as shown above. This is then the general solution, as pointed out in https://stackoverflow.com/a/3266791/1803897.

1
  • If you still have a question/problem, given that no one else has answered yet, consider editing your question to add the workaround you have so far, leaving Answerers to address the remainder. Thanks!
    – Jeff Schaller
    Jun 25 '19 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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