Vim plugin for Mplus statistical software files (.inp and .out).
- Syntax highlighting for keywords, commands, model operators, section headers, and comments
- Syntax-based folding for input sections and output blocks
- Indentation (section headers at column 0, body indented)
- Omni-completion (
<C-x><C-o>) for all Mplus keywords viasyntaxcomplete - UltiSnips snippets for common analyses (CFA, SEM, LGM, LCA, and more)
Mplus is case-insensitive and allows keywords to be abbreviated to four or
more characters, IS/ARE to be used in place of =, and section headers
to share a line with their content. This flexibility means input files
written by different people, or pasted from different sources, can look
inconsistent. The gq formatter normalises a selection (or the whole file
with gggqG) into a canonical style:
- Uppercase all code — Mplus convention. Quoted strings and file names keep their spelling.
- Expand abbreviations — e.g.
ANAL:→ANALYSIS:,ESTI =→ESTIMATOR =. An abbreviation of four or more characters is expanded to the option that Mplus reads it as, and only where Mplus reads a keyword: section headers, the option name that starts a statement, and theOUTPUTlist. An abbreviation is read as an option of the section it stands in, soESTI =becomesESTIMATOR =inANALYSISandESTIMATES =inSAVEDATA. Where two options start with the same four letters, Mplus takes one of them (INTEisINTEGRATION, andINTERACTIVEneedsINTER). AnOUTPUToption has one short form (SAMP,RES,MOD,CINT), and a shortening that Mplus rejects, such asMODI, is left as written. Variable names are left alone, soCLUSTER = clus;does not becomeCLUSTER = CLUSTER;. - Split section headers —
DATA: FILE = ex.dat;becomes two lines (DATA:on its own line, body indented below) so each section is delimited and folds correctly. - Replace
IS/AREwith=after an option name — all three are interchangeable in Mplus;=is shorter and more common. - Normalise whitespace — tabs → 4 spaces, trailing whitespace removed.
- Re-indent — section headers at column 0, body at one
shiftwidth. - Break long lines: Mplus reads the first 90 characters of an input line and drops the rest, so a title or code line that is longer after formatting is broken at white space.
TITLE sections and comments are left alone (whitespace cleanup only). A
title ends where Mplus ends it, at a line that begins with a command name
followed by a colon at once or after one more word (DATA:, anal:,
Model comparison:). A header that Mplus does not read, such as
mode indirect:, is left as written together with its section, since
Mplus passes over that section and would read it under MODEL INDIRECT:.
Text after the colon of a header that would be a header on a line of its
own (TITLE: Model comparison: two groups) stays on the line of its
header, where Mplus reads it as title text.
The formatter also sets fileformat=unix and fileencoding=utf-8 to avoid
encoding issues across platforms.
Other programs also use the .inp and .out extensions, so the plugin
reads the file before it sets a filetype:
- A new or blank
.inpfile ismplus-inp. A.inpfile with content ismplus-inpwhen its first line of code is an Mplus command header such asTITLE:,anal:, orMODEL INDIRECT:. Comments and blank lines above the header are allowed. - A
.outfile ismplus-outwhen it starts as Mplus output does, with the linesMplus VERSION ...andMUTHEN & MUTHEN. - A filetype that another plugin has already set is kept.
For any other file, run :setfiletype mplus-inp or :setfiletype mplus-out.
Plug 'li-ruijie/vim-mplus'{ 'li-ruijie/vim-mplus', ft = { 'mplus-inp', 'mplus-out' } }Or copy the contents to your Vim runtime directory.
| Command | Description |
|---|---|
:Mout |
Open corresponding .out file in vertical split |
:Mrun |
Run Mplus on current file (Windows/Linux) |
Requires UltiSnips. Type the trigger and press <Tab> to expand.
| Trigger | Description |
|---|---|
inp |
Full input file skeleton |
sec |
Generic section header |
cfa |
Confirmatory factor analysis |
sem |
Structural equation model |
lgm |
Latent growth model |
lca |
Latent class analysis |
gmm |
Growth mixture model |
mlm |
Multilevel (TWOLEVEL) model |
efa |
Exploratory factor analysis |
mc |
Monte Carlo simulation |
mi |
Multiple imputation |
AGPL-3.0