Question : Add an additional key named property2 and value value2

I am doing this Question : Add an additional key named property2 and value value2 and i have to
Edit the given yaml.
vi /home/bob/playbooks/practice.yaml

Update the file as below.
property1: value1
property2: value2

While running the command vi /home/bob/playbooks/property2: value2

it is giving me a attention message as below so the above command which I am using is correct ? I am sure something that I am not typing correctly in the command.

E325: ATTENTION
Found a swap file by the name “~/playbooks/.practice.yaml.swp”
owned by: bob dated: Mon Mar 25 20:19:30 2024
file name: ~bob/playbooks/practice.yaml
modified: YES
user name: bob host name: student-node
process ID: 1572 (still running)
While opening file “/home/bob/playbooks/practice.yaml”
dated: Mon Mar 25 20:13:27 2024

(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use “:recover” or “vim -r /home/bob/playbooks/prac
tice.yaml”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “/home/bob/playbooks/.pra
ctice.yaml.swp”
to avoid this message.

Swap file “~/playbooks/.practice.yaml.swp” already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Running a command :

You will see this message occasionally if you were running vim in background, and you try to edit the same file again in another call to vim practice.yaml. If that’s what you did, it’s probably best to choose Q, and foreground the backgrounded process.

The other thing to try is E, and vim will let you edit the file. You then do your edits, and save and quit normally.

Not working as per your comments. Just to check with you the command which I am typing is the correct one

vi /home/bob/playbooks/property2: value2

That looks decidedly wrong. vi NAME-OF-FILE is what you want. property2: value2 is likely content for the file. Doing it multiple times is probably why you are getting the Edit/Abort page.

You may need to get a bit more background on using the vi editor. We have a starter page in our Community FAQ. Start there.

Ok Rob thanks for the information but I need to know and want to understand that how I can write the command as per the below information to get the result

Edit the given yaml.

vi /home/bob/playbooks/practice.yaml

Update the file as below.

property1: value1
property2: value2

Below is the question :
There is a yaml file named practice.yaml under /home/bob/playbooks/ directory with a key property1 and value value1 .

Add an additional key named property2 and value value2 .

Very simply: you need to know a bit about using vi. Which is why I sent you to the guide. It’s an essential dev ops skill, so you really need to be able to do basic editing in vi. The guide will tell you the very basics; once you master those, it’s worth finding tutorials to get really good with the “vim” editor (the version of vi used in the labs and the exams).

In addition: here’s an interactive tutorial that might be easier to start with than the page I gave you: https://www.openvim.com/