When working with mercurial, I frequently do things like

vim <(hg cat -r 42 somefile)

However, if I try this with a file larger than several hundred lines, I get a Read Error in vim, and only the first couple of hundred lines are included. If I use gvim instead of vim, I get an error like

E211: FIle "/proc/3546/fd/63" no longer available

Isn't this supposed to work? I don't know if it's relevant, but I've tried both in bash and zsh, with the same result, and I also tried

cat <(hg cat -r 42 somefile)

which prints the entire file as I would expect.


Those are pipes, not regular files. It goes away when vim closes the file descriptor. You could do:

hg cat -r 42 somefile | vim -

(there vim is told it may not be a regular file so behaves accordingly. Use vim -R - or view - if you don't want vim to complain that the data has not been saved on exit).

Or with zsh, using a temporary file:

vim =(hg cat -r 42 somefile)
  • Thanks for your fast reply, though I'm not sure I understand what you mean by "It goes away when vim closes the file descriptor." The read error happens as I try to open the file. Also, just to clarify, I know I can't edit the file in this way, I just want to load it into vim to have a look around.
    – Tor
    May 7 '13 at 11:51
  • If it closes is, the next attempt to open it will fail. Typically, when you run gvim, gvim forks a process and probably does so after closing most fds in an attempt to disconnect from the terminal. May 7 '13 at 12:22
  • Ah, ok. Though the same happens when I try to open the file in vim in the terminal. And why does it manage to read part of the file? (I'm not trying to be difficult, I'm just curious about these things.)
    – Tor
    May 7 '13 at 12:48
  • @Tor, I can't reproduce it with vim <(seq 100000) for instance. In any case, I wouldn't expect a read error. What's the exact error you're getting? Note that if anything (like things that try to detect file type or get information from the file) called by autocmds open and read the pipe, what they read will be missing within vim. May 7 '13 at 13:30
  • When I open in vim in the terminal, the bottom line says for example "/proc/self/fd/11" [fifo/socket][READ ERRORS][dos] 238L, 8192C. The file is actually 2935 lines. It seems very random, though. It happens to some files which are 2500 lines, while some files at 3000 lines are fine. But whenever there is a read error, it reads 8192 characters.
    – Tor
    May 8 '13 at 7:20

Your Answer

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

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