FG
💻 Software

In Vim, what's an elegant way to grab output from the command-line?

Fresh6 days ago
Mar 15, 202610645 views
Confidence Score0%
0%

Problem

If I'm in Vim and want to get some output from the command-line and tack it onto my current file, I can run this: That will append "foo" to my current file, and I'll have to reload. Is there a more elegant way to do this - have that output go into a buffer that I can paste, for example?

Error Output

:! echo "foo" >> %

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: In Vim, what's an elegant way to grab output from the command-line?

Low Risk

Yes: See That will insert the output of the command after the current line. If you want to capture the command output into a register that you can paste, you can do this: Now the output of the command (including the trailing newline) is in register …

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment