gpt4 book ai didi

php - 从 vim 中运行 PHP 文件

转载 作者:可可西里 更新时间:2023-11-01 12:25:58 24 4
gpt4 key购买 nike

是否可以从 vim 中运行 PHP 文件?我在这里试图做的是有一个快捷方式,所以每当我需要运行我正在编辑的文件时,跳过退出 vim 和手动调用 PHP 解释器

最佳答案

是的!可以做你想做的事。两者都从 vim 中运行 PHP,并创建一个快捷方式。

Matthew Weier O'Phinney 写道:

Probably the most useful thing I've done as a PHP developer is to add mappings to run the current file through (a) the PHP interpreter (using Ctrl-M), and (b) the PHP interpreter's linter (using Ctrl-L).

Vim Productivity Tips for PHP Developers

例子:

:autocmd FileType php noremap <C-M> :w!<CR>:!/usr/bin/php %<CR>

或者(当心这不会检查文件类型)

:map <C-M> :w!<CR>:!/usr/bin/php %<CR>

Joe 'Zonker' Brockmeier 写道:

Vim also allows you to execute a command directly from the editor, without needing to drop to a shell, by using bang (!) followed by the command to be run. For instance, if you're editing a file in Vim and want to find out how many words are in the file, run

:! wc %

Vim tips: Working with external commands

关于php - 从 vim 中运行 PHP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5622236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com