Introduction
Today, most of us use Notepad++ (based on Scintilla) as our general purpose editor. Notepad++ provides a way to inject your own plugins. Just create your plugin and put its DLL file to the right location and you are done. Here is an example of writing plugin(s) for Notepad++ using your favorite language C#.
Background
The example plugin is a simple email plugin, that will allow the user to email current file's contents as email attachment. It allows the user to set mail server configuration and send emails using GUI injected by the plugin.
Email settings are stored in a text (.INI) file but password(s) are stored in encrypted format to provide a security layer for your credentials.
Using the Code
The source code is organized in a directory structure that is self-explanatory. Below is a short description of how directory structure organizes the code.
- Core/Npp - Contains classes to send commands to Notepad++
- Core/Scintilla - Contains classes that wraps scintilla types
- Core/Platform - Contains class(es) for DLL Imports
- DllExports - Contains class(es) for exported functions called by Notepad++ plugin system
- Forms - Contains Windows forms for GUI
The PluginUI
class contains the functions required for UI Registration with Notepad++. PluginExports
class is responsible to export the functions called by Notepad++. Please go through the below link to understand how Notepad++ plugin system works.
To deploy the plugin, compile the project and copy the DLL file to {Notepad++ Installation Folder}}\plugins folder or you can use Notepad menu Settings>>Import>>Import plugins for the same. Once the plugin is deployed, start Notepad++ and you will see the your plugin icon(s) on Notepad++ toolbar. You can also find your plugin under Plugins
menu.
Below are screenshots of installed plugin:
History
- 27th January, 2016: First version