Creating and Editing A New File With Vim: Goal

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Creating and Editing a New File with Vim

Goal:

The goal of this exercise is to practice creating files and editing them in vim. You'll also practice
changing between the normal mode, insert mode, and command mode. During this practice
exercise you will create a new file with vim, insert some text into that file, and save it.

Instructions:

Create a file

First, start a command line session on your local machine. Next, use vim to edit a new file named
myday.txt. To do that type, "​vim myday.txt​" at the command line and press <ENTER>.

vim myday.txt

Enter insert mode

You now have a new file opened and you're placed into normal mode. Press lowercase ​i​ to enter
the insert mode.

Add some text to the file

Next, start typing. Write a few sentences about the beginning of your day. If you make a mistake
while you're typing, you can press the backspace key to correct any errors.

Continue adding text to the file

Continue adding text to the file by typing three things you're grateful for. Once you're done typing,
press Escape to enter normal mode.

Save the file

Next save your changes. You should already be in normal mode, but if you're not sure you can also
press the Escape key again to be sure you are in normal mode. Next, type ​:wq<ENTER>​ to save the
file and exit vim.

http://www.LinuxTrainingAcademy.com
Verify the file was saved

You can verify that you've saved your changes by looking at the contents of the file. One way to do
that is to use the vim editor to open the file. Type ​vim myday.txt<ENTER>​.

vim myday.txt

You'll now see what you typed and saved into the file. Because we aren't making any changes and
don't want to save any changes, we can exit with ​:q!<ENTER>​.

http://www.LinuxTrainingAcademy.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy