Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer using Linux Ubuntu 1. What are the two Modes of VI? 2. type vi hello 3. Press a or i and Type the following

Answer using Linux Ubuntu

1. What are the two Modes of VI?

2. type vi hello

3. Press a or i and Type the following information:

Hello

How

Are you

Doing

4. Save and exit the editor. What command did you use to save and exit?

5. type: cat hello - What is the output?

6. Run the ls command. Do you see the file hello?

7. Now run the ls -l command. What are the permissions on the file hello?

8. Type the command, rm hello

9. Now type the ls command. Is the file hello still there? If not, why?

10. Type vi class

11. Enter this text:

I really

Enjoy this

UNIX class

And the labs

12. Save the file calling it class, WITHOUT exiting VI. What vi command do you use for this?

13. Now move the cursor over the y in really, and press the letter x. What happens?

14. Now put the letter y back in its proper place. Tell me TWO ways to do this (what commands).

15. Put the cursor on the letter A in And. Now type dd. What did it do?

16. Exit the file

17. Type vi class

18. Type in the text below

The Professor

Is pretty cool

too

20. Now type :q!

22. type cat class

21. What is the difference between the Visual Mode Command O, and the Visual Mode Command o?

22. What is the difference between the Visual Mode Command a, and the Visual Mode Command I?

23. What does the command, :q! do?

24. Use VI to Type in the file below

This is a test

25. Save it and name it toxicity

26. Using VI go back into the file and use the command mode command: /test

27. What happened?

28. Use the re-do command to repeat that search (If you are not sure of the re-do search command use the text book to find it).

Part 1: Creating a new file in vi

1. Create a directory called data if you do not already have one.

2. Change directories to the data directory.

3. To start the vi editor, type: $ vi filename

4. Use a new filename to create a new file.

a. For the new file, there will be tildes (~) on each line and the status bar at the bottom will indicate a new file.

b. opens in the command mode

c. type i to put vi in the text insert mode

d. press the ESC key to return to the command mode

e. type i and type in four lines of text.

f. Press ESC key and then type :wq followed by the return key to save your file and quit vi

g. Back in the UNIX command mode, select the cat command to view your new file contents.

5. Exit out of vi

II. Part 2: vi commands

1. Open vi with the file created in part 1.

2. For an existing file, it will be opened displaying its contents. Unused lines are preceded by tilde (~)

3. Type j at the command prompt to move the cursor down one line

4. Type k at the command prompt to move the cursor up one line

5. Type 2j at the command prompt to move the cursor down two lines

6. Play with the other cursor commands to get a feel for manipulating the cursor from the command line

7. You may find, particularly for smaller files, that it is easier to use the arrow keys in the text input mode to manage cursor movement

8. In larger files, combining cursor commands with change commands can make it easier to handle the changes.

9. Set the cursor in the upper left corner. If not still there, place vi in the command mode.

10. Type cw which is the change word command. This removes the word at the current cursor position and will place you in the text insert mode to allow you to change the word there. Do it and press ESC to get back to the command mode.

11. Repeat the same thing for the cc change line command.

12. Type r B to change the first character at the current cursor position to B. This will NOT exit the command mode!

13. Move the cursor to the start of the first line.

14. Move the cursor to the center of the first line using 20l command. That is 20 "Lowercase L" NOT 20 "one"

15. Type c$ to allow you to change the characters from the current cursor position to the end of the line.

16. Press ESC key to return to the command mode.

17. Move the cursor to beginning of a word in line 2.

18. Type dw to delete that word.

19. Type u to undo the last command, restoring the deleted word.

20. Type dd to delete the entire line

21. Type u to undo the delete and restore the line.

22. Place the cursor in the middle of the second line at the middle of a word.

23. Type xp to transpose the two characters at the cursor position.

24. Move the cursor left one character.

25. Type xp to transpose them back

III. Part 3: Cursor Movement

1. Copy the file, vitext from /home/global to your home directory

2. Open vitext in the vi editor.

3. In the command mode, use each of these commands and record the result on the table below:

Command

Effects from executing the command entered here

j

l

3l

k

h

w

b

$

5j

3h

IV. Part 4: Change Commands

1. Type the command :set number to set line numbers in your vitext file.

2. Place the cursor at the first character in line 1.

3. Type cw and type the new word Here in place of the first word.

4. Return to the command mode (ESC).

5. Type 4j to move down four lines.

6. Type the command cc and replace the current line with: by beverages, I mean the non-alcoholic kind.

7. Return to the command mode and move the cursor to the third word in line 6. What command did you use to move the cursor to the asked for position?

8. Type r t. What did this command do?

9. Type ~. What did this command do?

10. Type the following sequence of commands and record what each did(ESC after each):

Command

Effects from executing the command entered here

dw

dd

u

o

O

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Appoint a top official to direct the program.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago

Question

What attracts you about this role?

Answered: 1 week ago

Question

Understand the different approaches to job design. page 167

Answered: 1 week ago