notepad++

Useful plugins for developers

NppExec

NppExec [sourceforge] allows you to execute commands and scripts from a console window in Notepad++. It can be found in the menu bar at Plugins -> NppExec or just by simply hitting the F6 key (the shortcut Ctrl+F6 will run the latest command) .

Example: the following will

  • Set the console to output_var: on, meaning we can use the output of the console

  • run a SQL query from the file C:\scripts\query.sql

  • take the output from the console and put it into the active file at the cursor

  • close the console

  • clear the console

    NPE_CONSOLE v+ sqlcmd -S 111.111.1.1 -U UserName -P “password” -i C:\scripts\query.sql sel_settext $(OUTPUT) NPP_CONSOLE 0 cls

NppExec also allows you to save your scripts. After saving them, you can go to Plugins -> NppExec -> Advanced Options and run it anytime Notepad++ starts, closes, or even add that script to the Plugin commands using Macros. For example, by saving the above example as a “Run Query”, I could use the bottom left fields in the Advanced Options to add it to the menu.

Add to Menu

The script will be available as a macro after a restart of Notepad++ as long as the “Place to the Macros submenu” box is checked.

Finally, a shortcut can be assigned to the macro/command by using Settings -> Shortcut mapper -> Plugin commands.

TextFX

TextFX [SourceForge] is plugin for advanced character conversions (escaping characters etc.) and code formatting (HTML or C++ code).

JSON Viewer

JSON Viewer SourceForge is a plugin for JSON visualization and formatting. It is useful for indenting /formatting JSON documents and can be used to browse complex JSON file using a treeview tool.

The following image shows the commands offered by the plugin:

enter image description here

Starting from an unformatted JSON fragment (Example from https://www.json.org ):

{“glossary”: {“title”: “example glossary”,“GlossDiv”: {“title”: “S”,“GlossList”: {“GlossEntry”: {“ID”: “SGML”,“SortAs”: “SGML”,“GlossTerm”: “Standard Generalized Markup Language”,“Acronym”: “SGML”,“Abbrev”: “ISO 8879:1986”,“GlossDef”: {“para”: “A meta-markup language, used to create markup languages such as DocBook.”,“GlossSeeAlso”: [“GML”, “XML”]},“GlossSee”: “markup”}}}}}

To format and indent the code:

  • select all the json fragment
  • click “Plugins”/“JSON Viewer”/“Format JSON” or use the shortcut Ctrl + Alt + Shift + M

This is the resulting formatted code:

enter image description here

The plugin can also show a treeview browsable version of the JSON fragment:

  • select all the json fragment
  • click “Plugins”/“JSON Viewer”/“Show JSON Viewer” or use the shortcut Ctrl + Alt + Shift + J

The following screenshot shows how the plugin renders the JSON structure:

enter image description here

SourceCookifier

SourceCookifier parses the current source code for such components as class, function, and variable names and displays them in a tree view at a side panel. Navigation among these members is possible by double-clicking on the component name. The plugin supports a number of languages and customizations are possible for undetermined or user-defined languages. This is useful when working with large codes.

Example SourceCookifier

By default, SourceCookifier session mode is set to Single file mode. Other available modes are N++ session mode (all the files open in Notepad++) or Cookie session mode.

Cookie Session mode

To use Cookie session mode:

  1. Drag & Drop your folders with source code to Source Cookifier window

  2. Select the type of files you want to parse

Select file type

Notes:

  • You can save and load the cookie sessions; moreover, Source Cookifier display the history of the latest sessions
  • Opening the file of a saved session in Notepad++ will automatically switch SourceCookifier into cookie session mode and load this session
  • Maintaining a keyboard modifier (CTRL, SHIFT, or ALT - they are all similar) while drag-dropping the folder will fasten the parsing by only adding INCLUDES and not tags

Drad&Drop with keyboard modifier


Another useful feature is the ability to jump to the definition of a symbol (e.g. function)

  1. Select the right “session mode”: use cookie mode if the definition of the symbol is in another file not opened in Notepadd++, or single file mode if the definition is in the same file
  2. In Notepad++, put the cursor in the function/type you want to get definition of, and press CTRL+SHIFT+ENTER to jump to the definition. If there are several definitions, you can choose the file you want to open

Select file

  1. You can press ALT+LEFT to come back to the previous location (and ALT+RIGHT to go back to the definition)

Navigate Backward


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow