14
4
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:
:! echo "foo" >> %
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?
After looking at the help and experimenting, I see that 1)
:r
is short for "read" (so you can type out 'read' or just 'r' and it's the same command), and 2) doing:r path/to/foo.txt
will insert the contents of that file after the cursor. – Nathan Long – 2011-03-02T11:50:26.147Also - I didn't know about the
system
call. That's awesome! – Nathan Long – 2011-03-02T11:51:20.8401I also didn't know you could manually set registers like
let @a = 'foo'
. One cool idea would be, after doing a search and replace, you could save the search term to a register for pasting elsewhere by doinglet @a = @/
- "make the a register contain what the / register contains, namely, my last search." – Nathan Long – 2011-03-02T11:53:34.0071@Nathan Long: You're welcome. Other ways to paste from the / register are 1) to execute
:put /
to put the register contents on the next line and 2) while in insert mode, to type Ctrl-R followed by/
to insert the register contents at the cursor position. For more on those, see:help :put
and:help i_CTRL-R
. – garyjohn – 2011-03-02T15:25:30.853