如何将PHP / Python解释器集成到Notepad ++ [英] How can I integrate PHP/Python Interpreter to Notepad++
问题描述
我想要如果我正在编辑php文件,我是否应该可以按组合键或单击菜单项来启动php-cli并运行当前文件?
I want If I am editing a php file I should be able to press a key combination or click a menu item that'll launch the php-cli and run my current file? How do I do it in Notepad++.
我也需要Python。
Also I need this for Python.
推荐答案
老实说,我不建议您为Python安装IDE,除非您将其用于大型项目或用于大型项目,每天使用复杂的脚本。 Notepad ++与 NppExec 插件配合使用效果很好。我使用以下步骤:
I honestly don't recommend installing an IDE for Python unless you use it for large-scale projects or work on large, complex scripts on a daily basis. Notepad++ works great with the NppExec plugin. I use the following steps:
-
下载(如果尚不存在)NppExec插件并将<$ c $ [Notepad ++安装路径]中的c> .dll 文件>插件
在Notepad ++中打开Python文件,按 F6 执行
Open a Python file in Notepad++, press F6 to execute
在弹出的窗口中键入以下行:
Type the following lines in the window that pops up:
NPP_SAVE
python "$(FULL_CURRENT_PATH)"
以上几行基本上告诉NppExec保存当前的Python文件并使用首先在路径环境变量中出现的 python版本运行
单击保存,然后输入可识别的名称,例如 run_python
Click on "Save" and type in a recognizable name such as 'run_python'
转到菜单栏,插件- > NppExec->高级选项。
Go to the menubar, Plugins -> NppExec -> Advanced Options..
在菜单项下,选择我们上面刚刚创建的脚本,然后将其添加/修改到菜单中名称合适的项目。这使我们可以通过设置->快捷方式映射器->插件命令
Under 'Menu item', choose the script we just created above, and 'Add/Modify' it to the Menu items with a suitable name. This allows us to assign shortcut keys through Settings -> Shortcut Mapper -> Plugin commands
导航至脚本名称并选择任何快捷键,例如 Ctrl + R
Navigate to the script name and choose any shortcut keys like Ctrl+R
使用快捷键 Ctrl + R 保存并运行Python文件
Use the shortcut Ctrl+R to save and run the Python file
使用NppExec时需要注意的几点:
A few points to note when using NppExec:
-
确保已选中选项Plugins-> NppExec-> Follow $(CURRENT_DIRECTORY)。这样可以确保Python在当前路径而不是Notepad ++路径中查找脚本。
Make sure that you check the option Plugins -> NppExec -> Follow $(CURRENT_DIRECTORY). This makes sure that Python looks for the script in the current path, not the Notepad++ path.
停靠到的控制台窗口默认情况下,主编辑器窗口未打开自动换行。在控制台中使用 Ctrl + W 激活自动换行,并且不会丢失任何有用的输出数据
The console window that docks to the main editor window does not have word wrap turned on by default. Use Ctrl+W within the console to activate word wrap and not miss any useful output data
在控制台窗口中按 Ctrl + C 杀死正在运行的Python脚本
Kill a running Python script by pressing Ctrl+C within the console window
完成所有这些操作后,Notepad ++的功能基本上类似于IDE。它可能缺少 pdb
调试之类的功能,但它在Python上确实很好用。我很确定Perl / PHP脚本的执行步骤也差不多。
Once all this is done, Notepad++ basically functions like an IDE. It may lack features like pdb
debugging, but it works really well with Python. I'm pretty sure the execution steps for Perl/PHP scripts are also more or less similar.
这篇关于如何将PHP / Python解释器集成到Notepad ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!