Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First use Vim to edit a file, say /tmp/A.

Assuming that vim process is the only one that accesses /tmp/A, then use "ctrl+z" to suspend the process, and execute

fuser /tmp/A

Then you see nothing in the output.

However, if you use "less" to open that file, you could see the pid of less in the fuser output.

Is there anthing special about vim that makes this weird scenario?

share|improve this question
up vote 4 down vote accepted

Yes, vim does not open the file until it needs to save it. Instead, vim uses a temporary hidden swap file to save changes you make incrementally. Once you save the file (:w) it will write to the original file.

You can see that for yourself by using lsof, i.e.:

$ lsof -n -p `pidof vim`
vim     9695 gert    4u   REG  252,1    12288 410388 /tmp/.a.swp

This is common behaviour for editors. less just reads the file and it's of no benefit to use tricks when just opening a file for reading.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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