8

Is there any way to execute a command from notepad++ and have the results piped back into the program in a new tab?

1
  • 2
    AFAIK, this can be done with a plugin - whether or not said plugin exists already is an entirely different matter. Sep 8, 2011 at 16:25

3 Answers 3

2

If your program outputs plain text and you can run batch files...

  1. Create a batch file (e.g. dir.bat) which pipes the results of your command to a temporary file, then opens the file in Notepad++ e.g.

    dir > tmp
    "C:\path_to_notepad_plus_plus\notepad++" tmp
    

    (replace dir with your command and add an extension to tmp to syntax-highlight it appropriately).

  2. In Notepad++, select Run > Run... and browse for your batch file.

  3. If you use it often, consider saving it as a macro (Run > Run... > Save...) which you can access with a keyboard shortcut or under the Run menu.
1
  • Don't name the batch file dir.bat because dir is the name of built in command.
    – martineau
    Jan 6, 2022 at 16:18
2

For more flexible, you can install the NppExec plugin. The easiest way to install it is through the built-in Plugin Manager:

  1. Select Plugins / Plugin Manager / Show Plugin Manager
  2. Put a checkmark next to NppExec
  3. Click Install

After that, the fun begins. This tutorial is a good starting point on how to use this powerful plugin: https://micksmix.wordpress.com/2009/09/24/format-your-perl-scripts-using-perltidy-and-notepad/

It should work with any command-line utility that outputs text to the console.

1
  • Sorry, but it did not answer the OP's question of how to do it. Jun 16, 2022 at 17:30
1

Another option if you cannot install plugins and can only use Notepad++'s Run command is to utilize piping the output to the Windows clipboard which allows you to paste the output wherever you want.

As an example I use the following to checkout perforce files using the command line tool:

cmd /c "cd /d $(CURRENT_DIRECTORY) & C:\Progra~1\Perforce\p4.exe edit $(FULL_CURRENT_PATH) | clip"

The base of this is cmd /c "your_commands | clip" which runs a command, terminates the program when done and sends all the output to the Windows clipboard via the command clip.

After the command runs you can paste the contents of your clipboard somewhere (such as a new file) if you need or want the output.

1
  • Good tip, but I think you should explain that clip is a command included with Windows.
    – martineau
    Jan 6, 2022 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .