Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

vi: How do I save without exiting the editor?

Writer Matthew Harrington

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.

0

3 Answers

: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

1

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy