I'm running Windows and missing
vim; is it possible to use Notepad++ to run a command from the Windows command prompt and place the output in a notepad++ buffer?
It seems to be me the original Q is about Notepad++ supporting something similar to vi's ability to read the output (
stdout) of a shell command into the current doc (
general buffer in vi termonology),
ex line editor command )
r ( read )
! ( from the shell, the output (
stdout) of the command
ls into the current doc ( nothing specified, default is to read into
general buffer )
Notepad++ v 7.7.1 ( 32-bit ) Example
or navigate menu system, Run
menu to Run..
Enter the desired command into the textbox of the
notepad++ Run dialog,
cmd.exe /c echo %DATE% | clip
key or Click Run
Ctrl+V contents of clipboard into Notepad++ document.
Is it possible to use Notepad++ to run a command from the Windows command prompt and place the output in a Notepad++ buffer?
As far as I am aware, not directly. That said, a batch file might help in this case e.g.:
@rem Redirects both STDOUT and STDERR to e.g. cli_tmp.txt %* > C:\temp\cli_tmp.txt 2>&1 "C:\Program Files (x86)\Notepad++\notepad++.exe" C:\temp\cli_tmp.txt exit()
If you save this as ex. open_npp.bat and register it in your Windows
Path, you could then use ex.:
open_npp echo hello
at a command prompt and the text output from
echo hello (i.e.
hello) would appear in a new Notepad++ tab labeled as
cli_tmp.txt. Furthermore, you could use the Notepad++ Run... menu item to execute
cmd /k open_npp echo hello to get the same effect as running
open_npp echo hello from the command line.
The biggest drawback to this approach is that you'll likely want to copy the output or re-save your temp document with a different title each run, as your output will be typically overwritten each time the batch file is called.
As is, in the batch example given, output from STDERR is written to the temp file (vs. console) and the command window is closed immediately upon completion (
exit()). However, this behavior can obviously be changed.
This method likely won't catch interactive command input/output properly. Likewise, if a process hangs or takes forever, you might be stuck guessing about what's happening.
I have never had an issues using this kind of batch file but there could always be edge cases. =P
You can use pork2sausage. Just open Plugins Admin in newer Notepad++, or install Plugin Manager in older versions, then install the plugin from there. Otherwise go to the Plugin Central and download the zip file manually
The plugin transforms a selected text to whatever you want, once your transformer (a console program which takes inputs then generates an output) is set properly with Pork to Sausage plugin.
The attractive part of this plugin is its flexibility: one (or more) small program(s) can be written in any language (such in java or .Net), or usage of the other programs in order to transform your selected text in Notepad++.
Up to 20 commands are customizable.
After installing open Plugins > Port to Sausage > Edit user commands and add whatever command you want. Here's an example to convert the selected text to uppercase (of course in reality you should use the built-in case conversion from Notepad++)
[toupper] progPath=C:\Windows\System32\cmd.exe progCmd=cmd /c "echo $(SELECTION) | tr [:lower:] [:upper:]" workDir=C:\Users\...\tmp
However to make the above example work with new lines you need to add 2 more options
progOutput. You can also prevent the output to overwrite the selected text with
replaceSelection. You can find more information in the plugin's comment