search

Home  >  Q&A  >  body text

How to run unsaved code when editing PHP with vim

I use vim to edit php files. If you save them, you can use !php% to run the current file
But I want to verify the accuracy of the code without saving it. Is this possible?

某草草某草草2743 days ago633

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 16:44:53

    Under Linux

    :%w !tee | php

    Explain:

    The parameter after Vim’s w command can be used to specify the saving path. We use the !tee 命令是使用 shell 的进程替换让 w command here to write to the pipe for use by any subsequent commands.

    ---------

    @felix021 pointed out that you can directly write w to the standard input of php without process replacement.

    :%w !php

    reply
    0
  • Cancelreply