16

I always using :wq to save a file. Today, I came to know that :x can be used to do that. But I didn't notice it in any vi-tutorial or vi-quick-reference. Is there any difference between these two commands?

Mohammed H
  • 6,880
  • 16
  • 81
  • 127

2 Answers2

26

From

help :x

    *:x* *:xit*
:[range]x[it][!] [++opt] [file]
            Like ":wq", but write only when changes have been
            made.
            When 'hidden' is set and there are more windows, the
            current buffer becomes hidden, after writing the file.
bua
  • 4,761
  • 1
  • 26
  • 32
0

The difference between those two is very simple- :x saves changes to the file only if it has been modified while :wq changes the modification time no matter what.