Any way to save changes in vi without exiting the editor? I'm experimenting with php and checking my work in the browser. To get back to my code I have to reopen the php file which is an extra step.
Thanks.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this community:w
to save
:q
to quit
:q!
to quit in spite of unsaved changes
I'm assuming that you are asking becasue you have been using combination of the two :wq
These commands operate only on the current buffer:
:write
, or :w
to save
:update
, or :up
to save only if changes were made (vim only)
:wq
to save (current buffer only) and quit
:exit
, or :x
to save (current buffer only), but only if changes were made, then quit
These all have 'force' variants, e.g. :wq!
, to write the current buffer and quit, even if other buffers contain unsaved changes.
Multiple buffers:
:wall
, or :wa
to write all buffers which have changed (vim only)
:wqall
, or :wqa
to write all changed buffers, then quit (vim only)
Shortcuts:
The key sequence ZZ
in normal mode is a shortcut for :exit
The key sequence ZQ
in normal mode is a shortcut for :q!
(vim only)
:w filename
This will write to that specified filename.
... useful when you're trying to track changes and not overwrite.