Saving Files in Vim

Mike Hartington
InstructorMike Hartington
Share this video with your friends

Social Share Links

Send Tweet

We've learned how to add text in Vim using insert mode, now what about saving that file? We'll go over how to use Vim's write command.

[00:00] In our last video, we learned how we could add text to a file using Vim's insert mode. Let's start Vim again, enter insert mode, and start adding some text.

[00:16] Now that we have text in our buffer, we want to be able to save it to disk. This can be done using Vim's write command. Let's exit out of insert mode and head to command mode. For this file, let's try to call the write command.

[00:32] You'll notice an error message appears in the bottom left. If you try to write a new file in Vim but don't supply a file name, you'll receive this error.

[00:41] Let's run the write command again but supply a name and an extension. Now, if we quit Vim, we can open the file again by running Vim and then the file name. The write command can also be run with the shortcut :W.