How to run Notepad ++ Python

I recently learned about a text editor called Notepad ++ and it was easy to use, so I started using it. So, open the command prompt yourself and execute it. Since the operation was troublesome, I made it possible to execute it just by pressing Ctrl + F5 on Notepad ++, so I would like to make a note of that up to this point. ** Caution ** It is assumed that Python is built on Anaconda on Windows. Also, please note that this article does not describe how to install Python itself.

Notepad ++ installation

https://notepad-plus-plus.org/ Please open the official website above and click download under home displayed on the left side. Click the link under Download 32-bit x86 or Download 64-bit x64 on the site you opened to download. (If you don't like zip, choose what you want.) 32bit Notepad++ zip package 32-bit x86: Don't want to use installer? Check this one (zip format). 64bit Notepad++ zip package 64-bit x64: Don't want to use installer? Check this one (zip format).

If you can download it, unzip it in your favorite location. Rename the unzipped file and move it to any location you like.

Notepad ++ settings

First, let's set from Japanese localization.

Localizing into Japanese

Let's open the file that you renamed or moved to a location of your choice. Then, open notepad ++. Exe in the red square in the image below. file2.png After opening, click Settings → Preferences from the menu. (Click the red square in the image below.) file1.png Click General from the left list on the screen that appears, and click Japanese from the Localization drop-down list on the right. (Click the red part in the image below.) file3.png Now you can translate it into Japanese. Next, set the tab. However, if you don't need to replace tabs with spaces, skip the next tab setting.

Tab settings

Select the language menu from the list on the left side of the environment setting screen that was opened when you translated it into Japanese. Once you have made your choice, check the checkbox to the left of Replace with a space. file4.png This completes the tab settings. Press the close button at the bottom to close the dialog. Next, set the half-width space and tab display. (If you do not need this setting, skip the next half-width space and tab display settings.)

Half-width space and tab display settings

First, click View → Show Control Characters → Show Half-width Spaces and Tabs from the menu. (Click the red part of the image.) file5.png This completes the settings.

Set it so that it can be executed by simply pressing Ctrl + F5 on Notepad ++.

Creating a batch file

First, reopen the file that you renamed or moved to a location of your choice. In that file, right-click in the margin etc. → New → Select Text Document to create a text file. file6.png Let's rename the created text document to python_exe.bat. file7.PNG If you make changes, you may see this screen, but click Yes. Then right-click on the `` `python_exe.bat``` you just created and click Edit. (You can reopen it from Notepad)

** Caution ** If you name it `python.bat``` or `cmd.bat``` here, a loop may occur at runtime and it may not end. Be careful when naming.

Write the following in the opened notepad. If you haven't built a Python virtual environment with Anaconda

python


@echo off
call python "%1"
pause

If you are building a Python virtual environment with Anaconda

python


@echo off
call activate virtual environment name
call python "%1"
call deactivate
pause

*** Caution ** In my environment, since I am building a virtual environment with Anaconda, I am using the code written below. The code I wrote above doesn't work, so if you've tried it and it doesn't work, check it out or use something other than this article.

After writing in Notepad, save it by overwriting and close it.

Set so that it can be executed simply by pressing Ctrl + F5.

Let's create a python file to execute temporarily. Notepad ++, which has been open since earlier,

python


print('Hello World')

And press * Save As * from the file. Then select the file type ``` Python file (* .py; *. Pyw)` `` and save it with a name of your choice. As it is, click Run → Run from the menu (click the red square in the image below.) file9.png Once opened, enter the following in the drop-down list: (If you changed the name of the batch file, please change the part of python_exe.bat.)

$(NPP_DIRECTORY)\\python_exe.bat $(FULL_CURRENT_PATH)


 ![file10.png](https://qiita-image-store.s3.amazonaws.com/0/199097/b0035d62-b74a-91fa-d9a5-41c7ac7ff310.png)

 Then press the register button.
 Then, you will see a screen like the one in the image below, so enter Python for the Name.
 Also, check the checkbox to the left of CTRL and
 Select F5 from the drop-down list on the right that says None and select the OK button.
 ![file11.png](https://qiita-image-store.s3.amazonaws.com/0/199097/49fd694d-4876-e999-8185-fcf6c805de08.png)
 Then, close the execution ... dialog with the X button.
 This is the end.

 Finally, press ctrl + F5,

Hello World Press any key to continue. . .

 If it comes out, it means that the setting was successful.

 If you have any mistakes or precautions, it would be helpful if you could point them out.

# Supplement (32-bit version only, how to install Plugin Manager and NppExec)
 In the comment, only the 32-bit version is available, but I have told you how to install NppExec, so I will supplement it.
 Notepad ++ 7.5 does not include Plugin Manager in both 64-bit and 32-bit versions.
 The reason is that the embedded version is currently being created to avoid the inclusion of advertisements in the Plugin Manager.
 However, the 32-bit version seems to work by porting an older version of Notepad ++.
 I will explain how to do this.
 ※**Caution**
 Under this, by using an older version of Plugin Manager, in the 32-bit version of Notepad ++ 7.5
 It enables the Plugin Manager, but something may go wrong.
 Therefore, please install Plugin Manager from here onward at your own risk.
## Introduction of Plugin Manager
 First, the 32-bit version of Notepad ++ 7.5 was explained at the beginning of this article, so I will omit it.
 Then go to the official page below.
https://notepad-plus-plus.org/download/v7.4.2.html 
 Under Download 32-bit x86 on the site
Notepad++ zip package 32-bit x86: Don't want to use installer? Check this one (zip format).
 Download the old version from where it says.
 Next, unzip the downloaded one and open the plugins in that folder (red square in the image) (1)
 ![file12.png](https://qiita-image-store.s3.amazonaws.com/0/199097/b2b6664b-a1b2-4042-17df-6955318770df.png)
 Then, at the beginning of this article, open the renamed or moved file. (2)
 Similarly, let's open plugins.
 (1) Copy PluginManager.dll from the plugins opened in (1).
 ② Paste it in the plugins opened in (2).
 ③ Open the Config folder in the folder (1), copy PluginManager.ini in it, and
 ④ Open the Config folder in the folder (2) and paste it in it.
 After completing the above operations, if you start (2), you will find that Plugin Manager is increasing in the plugins in the menu.
## Introduction of NppExec
 Use the one added in the introduction of Plugin Manager.
 First, click Plugins → Plugin Manager → Show Plugin Manager in the menu. (Click the red square in the image below.)
 ![file13.png](https://qiita-image-store.s3.amazonaws.com/0/199097/9beaf5be-b04e-c491-d0fb-8b23e8422cc5.png)
 Click to open the Plugin Manager, click the Updates tab and click
 Make sure that the left side of Plugin Manager in it is checked.
 Then click the Update button.
 When the update is complete, a screen like the one in the image below will appear. Click Yes. (A confirmation screen for User Account Control may appear in between, but in that case, please allow it.)
 ![file14.PNG](https://qiita-image-store.s3.amazonaws.com/0/199097/068e01d7-0a69-d60d-f607-fc25a1fd0cdd.png)
 Then Notepad ++ disappears and reopens.
 Once again, open Plugins → Plugin Manager → Show Plugin Manager in the menu.
 If you see Plugin Manager in the list on the Updates tab, check it and update again.
 Also, open Plugins → Plugin Manager → Show Plugin Manager in the menu.
 Now find NppExec in the list view in the Available tab and check the checkbox on the left.
 Then click the Install button.
 ![file15.png](https://qiita-image-store.s3.amazonaws.com/0/199097/ab417bdc-3cc3-1225-a61c-387d50f6bd81.png)
 When the installation is complete, a screen like the one in the image below will appear. Click Yes.
 ![file16.png](https://qiita-image-store.s3.amazonaws.com/0/199097/550b8625-2651-50b7-01df-54744a431947.png)
 If you click it, it will be restarted, so if NppExec is added in the plugin of the menu after startup, it will end.
# Reference site
https://notepad-plus-plus.org/news/notepad-7.5-released.html
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/3651
https://so-zou.jp/software/tech/tool/editor/notepad-plus/plug-in/nppexec/

# environment
OS Windows 10 Pro (64 bit)
Notepad++ 7.5
Anaconda-4.2.9
Python 3.5.2


Recommended Posts

How to run Notepad ++ Python
How to install Python
How to install python
How to run a Maya Python script
How to run MeCab on Ubuntu 18.04 LTS Python
How to run Leap Motion in non-Apple Python
[2020.8 latest] How to install Python
How to install Python [Windows]
python3: How to use bottle (2)
[Python] How to use list 1
How to update Python Tkinter to 8.6
How to use Python argparse
Python: How to use pydub
How to change Python version
How to develop in Python
[python] How to judge scalar
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
[Python] How to run Jupyter-notebook + pandas + multiprocessing (Pool) [pandas] Memo
How to run python in virtual space (for MacOS)
How to run tests in bulk with Python unittest
How to run setUp only once in python unittest
How to install python using anaconda
How to write a Python class
[Python] How to FFT mp3 data
Python: How to use async with
[Python] How to use Pandas Series
How to collect images in Python
How to use Requests (Python Library)
How to use SQLite in Python
How to get the Python version
[EC2] How to run selenium webdriver
How to get started with Python
[Python] How to import the library
[Python] How to use list 3 Added
How to use Mysql in python
How to use OpenPose's Python API
[Python] How to swap array values
How to wrap C in Python
How to use ChemSpider in Python
How to use FTP with Python
Python: How to use pydub (playback)
How to use PubChem in Python
How to speed up Python calculations
How to calculate date with python
How to access wikipedia from python
How to use python zip function
[Nanonets] How to post Memo [Python]
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
[Python] How to use Typetalk API
How to run a Python file at a Windows 10 command prompt
How to run a Python program from within a shell script
Don't lose to Ruby! How to run Python (Django) on Heroku
How to run an app built with Python + py2app built with Anaconda
Updated to Python 2.7.9
How to package and distribute Python scripts