Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Vi 1. in a shell, type vi editor 2. press ‘i’ to switch vi into Insert Mode 3. E

ID: 3818898 • Letter: V

Question

Vi

1. in a shell, type vi editor

2. press ‘i’ to switch vi into Insert Mode

3. Enter the following text:

The squick

browne

foxy will rereturn.

4. What key do you press to exit Insert Mode?

5. How do you save the file?

Q: When you have the file, does the command appear in the shell?

Still using the “editor” text file…

1) Create a new text file, “edited” by concatenating the “editor” file with itself.

QA: what is the exact command you used?

2) Count the number of lines in the “edited” file using one command with a single option.

QB: what is the exact command you used?

3) Open the “edited” file using Vi. In command mode, turn line numbers on using :set number.

QC. does the number of lines match your output from step 2 above?

4) Use two characters (not the down arrow!) in command mode to move to line 3.

QD. what characters did you enter?

5) Delete the entire line using two characters

QE. what characters did you enter?

6) Immediately paste the deleted line.

QF. what command did you use to paste?

QG. so, deleting the line didn’t actually “delete” it…where did the line go?

Explanation / Answer

Vi

1. in a shell, type vi editor

2. press ‘i’ to switch vi into Insert Mode

3. Enter the following text:

The squick

browne

foxy will rereturn.

4. What key do you press to exit Insert Mode?

esc

esc key will exit from insert mode.

5. How do you save the file?

:wq filename

example :wq test.txt

Q: When you have the file, does the command appear in the shell?

No

Still using the “editor” text file…

1) Create a new text file, “edited” by concatenating the “editor” file with itself.

QA: what is the exact command you used?

cat editor editor >> edited

2) Count the number of lines in the “edited” file using one command with a single option.

QB: what is the exact command you used?

wc -l edited

3) Open the “edited” file using Vi. In command mode, turn line numbers on using :set number.

QC. does the number of lines match your output from step 2 above?

Yes

4) Use two characters (not the down arrow!) in command mode to move to line 3.

QD. what characters did you enter?

3j

5) Delete the entire line using two characters
QE. what characters did you enter?

dd

6) Immediately paste the deleted line.

QF. what command did you use to paste?

p

QG. so, deleting the line didn’t actually “delete” it…where did the line go?

In the buffer