What is the difference between ZZ and :wq commands?
Answers were Sorted based on User's Feedback
Answer / stan reichardt
ZZ will quit the file, it will only save the file if there
have been changes to it. Therefore the timestamp on the
file will only change if there have been changes.
The ":wq" will save the file with or without any changes
being made. Therefore the timestamp wil always be changed.
Is This Answer Correct ? | 29 Yes | 3 No |
Answer / pravin
I guess both do the same task..! in the sense :wq,:x and ZZ
are used to save the changes of edited to storage and quit..
but to jot down the difference a foolish one.. :wq and :x
requires <enter> key to be pressed to fire this commands
where as ZZ works as a shortcut (hot) key.. it some what
like for prior commands we are requesting Vi to do the work
and later command we are telling/commanding
Is This Answer Correct ? | 8 Yes | 4 No |
Answer / 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 |
Answer / surendra
ZZ is the command mode comand in uix to save and quit file.
:wq is the execute command mode command to save and quit
file.
Both does the same job
Is This Answer Correct ? | 4 Yes | 5 No |
what are the different delete commands used in vi editor?
what are the different commands used to quit from the vi editor?
How to replace String "a" with String "b" in whole file of the vi editor?
What does the /text command do?
What is the difference between lettered buffer and temporary buffer?
How to append a file to current file?
What is the difference between ZZ and :wq commands?
what does the c$ command do from command mode?
HOW WE CAN MAKE THE DLIEVERY WHICH IS BLOCKED DUE TO CREDIT LIMIT.
How to return to shell without leaving vi editor?
what is the command used to append text after current line?
what is the command used to set margin in vi editor?