How can I integrate PHP/Python Interpreter to Notepad++

巧了我就是萌 提交于 2019-12-11 12:38:00

问题


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

Also I need this for Python.


回答1:


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:

  1. Download (if it does not already exist) the NppExec plugin and place the .dll file in [Notepad++ installation path]\plugins

  2. Open a Python file in Notepad++, press F6 to execute

  3. Type the following lines in the window that pops up:

    NPP_SAVE
    python "$(FULL_CURRENT_PATH)"
    
  4. The above lines basically tell NppExec to "save the current Python file and run it using the version of python that first appears in the path environment variables"

  5. Click on "Save" and type in a recognizable name such as 'run_python'

  6. Go to the menubar, Plugins -> NppExec -> Advanced Options..

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

  8. Navigate to the script name and choose any shortcut keys like Ctrl+R

  9. Use the shortcut Ctrl+R to save and run the Python file

A few points to note when using NppExec:

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

  • 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

  • Kill a running Python script by pressing Ctrl+C within the console window

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.




回答2:


You could check out the "Run" menu option. It allows you to bind key combinations to applications.



来源:https://stackoverflow.com/questions/9001046/how-can-i-integrate-php-python-interpreter-to-notepad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!