In macOS Catalina, from Terminal, bash, vim 8.1, I launch vi <(command1) to see the output of a command.
From another terminal, I launch another vi <(command2).
Then vim complains that it's already found a swap file of that name.
(In the process listing, all commands appear as vi /dev/fd/63. Always 63.)

In Linux, the swapfiles are named differently, e.g. 'pipe:[267258].swp' for some random number 267258.
Can macOS's vim do this too, instead of always using 63.swp?

  • 2
    Process substitution creates a file backing a command—it is implicitly replaced on the command line so that vi only ever sees the name of this pseudo-dile. If it happens to always use /dev/fd/63 (a file ive frequently observed on mac), it’s really a bash-mac issue. That said, if you have more than one proc-sub in the same command, they should use different numbers. Finally, for this sort of use less is usually a better choice (or set up vim as your manpager, if your command is man). Vipe is also not bad.
    – D. Ben Knoble
    Mar 5, 2020 at 4:13
  • 2
    Also try this: command1 | vi -
    – filbranden
    Mar 5, 2020 at 4:39
  • 1
    @filbranden I'd accept piping to stdin as an answer, a workaround that creates no swapfiles. Mar 5, 2020 at 17:04
  • @CamilleGoudeseune Just wrote that as an answer. (Sorry it took me a while to get to it.) You actually do get a swapfile when using stdin, but a separate one for separate calls of Vim. (See answer for more details.) Cheers!
    – filbranden
    Mar 7, 2020 at 22:06

1 Answer 1


The reason why command redirection through <(...) resolves to a unique name on Linux is due to the Linux kernel exposing these as virtual symlinks to such unique name.

You can easily verify that, on Linux, with a command such as:

$ ls -l <(echo hello)
lr-x------ 1 filbranden filbranden 64 Mar  7 13:37 /proc/self/fd/63 -> 'pipe:[75220421]'

One way to work around the fact that Vim sees these command substitutions as the same file on Mac OS is to simply have Vim read the contents of the file through standard input, by passing it a - as the filename:

$ command1 | vi -

In that case Vim will use a swap file with an empty name (./.swp) but when running the same for further commands, Vim will know it's not the same file and it will create separate swap files (./.swo, then ./.swn etc.) for them, which should work around the issue you're experiencing.

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.