Vim Save As – Save existing File to a new file in Vi/ Vim Editor Easy way

Vim Save As  – Save existing File to a new file in

Vi/ Vim Editor Easy way 2020

Vim Save As – Save existing File to a new file in Vi/ Vim Editor Easy way. Vi/ Vim editor is one of the most favorite editors available in the Linux/ Unix world. Some people love Nano but personally I love Vi/ Vim due to its power and easy to use methods. However, if you are new to the Linux World you must be struggling with basic commands and even working with an editor can become a nightmare. So in this very short guide, we will learn how to use save as an option in a Vim and save content in a new file. This guide will work on all the Linux flavors Ubuntu, Centos, Redhat Servers.

 

Follow these instructions to use Vim Save as.

  • Let’s open or create a new file in the Linux from the terminal and add some content to it. To do that use the following command.

           vim  Filename.txt or vim filename.txt

  •  Now type  “i “ to get into the insert mode and type your text.

Vi insert Mode

  •  Now press ESC on the keyboard and then type  :w . This will save the existing content in the file.If your existing file name is  “Test.txt “. Now if you want to save this file with a different name(test2.txt), then follow the below-mentioned commands.

         :w  test2.txt

         :x  test2.txt

  • If you want to save the existing file to a new location then simply add the path after   :w

Example :    :w /home/ubuntu/test.txt

If you are having any issue using these commands, then add a comment in this section. We will surely try to help you out.

Leave a Reply

Your email address will not be published. Required fields are marked *