1

How do I rewrite this line of code

call system("cp /tmp/foo.txt /tmp/bar.txt")

into a vim command which is more portable and OS-independent?

I've been looking around but checking for "vimscript copy file / folder" surprisingly doesn't show any results.

Important: I need to also know how to copy folders using vimscript, too. Not make a new folder, but copy one which already exists.

2
  • I know there is an excerpt in :h writefile() detailing copying files, no idea for folders. – Jake Grossman Oct 18 '20 at 19:23
  • 1
    Might take a look at tpope’s eunuch plugin for inspiration – D. Ben Knoble Oct 18 '20 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.