从vim中运行PHP文件 [英] Run PHP file from within vim

查看:254
本文介绍了从vim中运行PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possibly to run a PHP file from within vim? What im trying to do here is having a shortcut so whenever I need to run the file I'm editing to skip exiting vim and calling the PHP interpreter manually

推荐答案

是的!可以做您想做的事.两者都从vim内运行PHP,并创建了快捷方式.

Yes! It's possible to do what you want. Both running PHP from within vim, and creating a shortcut.

马修·韦尔·奥芬妮写道:

Matthew Weier O'Phinney writes:

可能是我最有用的东西 作为PHP开发人员完成的工作是添加 运行当前文件的映射 通过(a)PHP解释器(使用 Ctrl-M),以及(b)PHP解释器的 短绒毛(使用Ctrl-L).

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).

针对PHP开发人员的Vim生产力提示

示例:

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

或者(这不会检查文件类型,请注意)

Or (this doesn't check the filetype beware)

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

Joe'Zonker'Brockmeier写道:

Joe 'Zonker' Brockmeier writes:

Vim还允许您执行 直接从编辑器命令 无需掉到外壳上, 在命令后使用bang(!) 要运行.例如,如果您 在Vim中编辑文件并想要查找 找出文件中有多少个字, 运行

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中运行PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆