What is the difference between ZZ and :wq commands?
Answer Posted / ali ahsan
Both do the same job
I can't speak for others, but for myself, I prefer the ":wq".
While it may be two extra characters, I like that my mind goes through the process of "I want a command (:) that writes the file (w) and quits (q)".
It allows me to adjust my intent on the fly...do I mean "and overwrite any pre-existing file" then I
add a "!". If I really mean "do it for all the files", I can add an "a".
So my mind goes through the process of the checklist:
- do I want to write the file? (w)
- do I want to quit the file? (q)
- do I want to quit ALL the files? (a)
- do I want to write/abandon any changes? (!)
and build the command accordingly.
That's 16 different available options in some situations, whereas ZZ and ZQ only account for two of them.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers