Run Mplus from Notepad++

I use Mplus for multilevel models or structural equation modeling from time to time. However, I prefer to edit the input file in Notepad++ because it has richer options to edit text files such as column mode editing.

But instead of edit -> save -> close in Notepad++ and then open -> run in Mplus, there should be an easier solution. I always knew that this option existed, but today I put that feeling into practice.

In this blog post, I will show you how to setup Notepad++ (on Windows) so that you can run the currently open Mplus input file with a single keyboard shortcut.

First, you have to install a plugin for Notepad++ called NppExec. In Notepad++, go to Plugins -> Plugin Manager and select and install NppExec.

Second, open the “Execute” option of the NppExec plugin by pressing F6. Then you can write any commands you like to be executed from a command line. For Mplus, this should be something like:

"C:\Program Files\Mplus\Mplus" $(FULL_CURRENT_PATH) $(NAME_PART).out
// rundll32 user32.dll,MessageBeep

The first command npp_save saves the current file, which should be the Mplus input file. The second command sets the directory of the input file as the working directory. The third command simply runs this input file from the command line. You can learn more about the usage of environment variables such as $(FULL_CURRENT_PATH) in the documentation of the plugin. The fourth command opens the output file. If you remove the commenting // in the last line, a beep will be played on Windows machines to notice you that Mplus has finished.

Pressing OK will execute these three commands.

Third, you can assign a keyboard shortcut to this procedure which is really useful:

  • Press F6, specify the command as described above and instead of pressing OK press Save and save using a custom name.
  • Go to Plugins -> NppExec -> Advanced Options and choose an “Associated script”, namely, the script you just saved. Press Add/Modify and then OK, Notepad++ needs a restart.
  • Finally, in Notepad++, go to Settings -> Shortcut Mapper -> Plugin commands. Select the script you just saved and assign it a shortcut of your choice.
  • Done.

This gives you the ability to run any Mplus file from within Notepad++, and this is really handy if you have to do complex edits on a single Mplus file. Of course, for running multiple Mplus files, there is nothing better than the R package MplusAutomation.


comments powered by Disqus