vi: How do I save without exiting the editor?

: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.

Tags:

Vi