1

I'd like to append a custom string at the end of the file.

For example using :read command this works:

:$r !echo my string

however is there any more portable way of doing that (without executing external program)?

I've tried:

:$r "my string"

but it's just duplicating content of my file (the same as: :$r %).

How to I specify literal string in this context?

2
  • 1
    :call append('$', 'my string') - not using a replace command though. And by the way, :r is read, rather than replace. Commented Oct 17, 2015 at 12:56
  • @SatoKatsura You're right, I've corrected the title. I think I got confused by: :help r.
    – kenorb
    Commented Oct 17, 2015 at 17:01

2 Answers 2

6

Yes, you can use :put:

:$put='my string'

See :help :put.

0

I know 7 years too late and no one will probably read this... And I like @romainl answer more, but this is possible too:

:r !echo $(cat %) my string

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.