Linux+ 1.5 Text Editors

Linux+ Certification Exam
STUDY
PLAY
Vim Commands
Vim (vi improved), also referred to as vi, is a utility that creates and modifies text files. It is the standard command-line text editor included with Linux distributions. Vim has the following modes:

Command mode is the initial mode vim uses when started. It has commands that cut and replace text, and it is the mode vi uses to enter the other modes.
Command line mode is the mode that works with the file system. Use it to save files after editing them.
Edit mode is the mode that vim uses to write and edit text in the file. It has two operation modes:
Insert mode adds text between the preceding and subsequent text.
Replace mode overwrites subsequent text.
Use... To... Mode
vi Start vim. Type the command at the shell prompt. N/A
vi filename Start vim and immediately begin working on the named file (either a new, non-existent file or an existing file). Type the vi command at the shell prompt. N/A
Insert key
i
s Enter insert mode from command mode Command
Esc key Enter the command mode from the edit mode. Insert/Replace
Delete key Delete text Insert/Replace
Insert key Change between insert and replace mode while in edit mode. Insert/Replace
# (line number) Go to a specific line in the document while in command mode. For example 94, moves the cursor to line 94. Command
dw Cut a whole word and trailing space. Command
de Cut a whole word but omit the trailing space. Command
d$ or D Cut all text following the cursor to the end of the line. Command
dd Cut a line from the text. Command
p Place text in memory into the document. Command
u Undo the last action. Command
o Open a new line above the current line. Command
Ctrl+g Display file name, total number of lines in the file and the cursor position. Command
/term Search forward for all instances of a term. Press n to go to the next term and N to go to the previous term. Command
?term Search backward for all instances of a term. Press n to go to the previous term and N to go to the next term. Command
yy Copy a line of text into memory. Command
a Append text after the cursor Command
A Append text after the current line Command
C Change text from current cursor position to the end of the line. Command
cc Change text of the entire line. Command
ZZ Save current file and exit vim. Command
h Move the cursor one space to the left. Command
j Move the cursor down a line. Command
k Move the cursor up a line. Command
l Move the cursor one space to the right. Command
z Exit without saving Command
: Enter command line mode from command mode Command
w Save the current document. Command line
w filename Name and save the file. Command line
w! filename Overwrite the file Command line
q Exit vim. This produces an error if the text was modified. Command line
q! Exit vim without saving. Command line
wq or exit Save the document and exit vim. Command line
e! Reload the file from the last saved version. This discards all edits and reloads the last saved version of the file into vim. Command line
While in vo command mode, you need to copy an entire line of text. What command should you use? (Tip: Enter the command as if in command mode.)
yy
You made a few changes to the /grub/grub/grub.conf file and now you need to exit out of insert mode, save tge canges, and quit. What should you do? (select two. Each answer is a required part of the solution.)

Type :w!
Press Esc
Type :q!
Type :wq
Press Esc
Type :wq
Which ket conbination should you press in vi to save the file you are working on and quit?
:wq
You are editing a text file in vi and need to open a new line above the one you are currently working on. Which key shoud you press to accomplish this?
O
Which of the following commands will cut an entire line from a file while in vi command line mode?
de
dd
C
yy
dd
What are the two methods to exit vi from command mode?
Type yy
Type ZZ
Type :wq
Type :e!
Type ZZ
Type :wq
Match the vim mode on the left to the correct definition on the right
Command Mode The Mode that vi uses to write and edit text in the file.
Command line mode. The initial vim mode used when vim is started. It has commands that cut and peplace text, and it is the mode vi uses to enter other modes.
Edit Mode The mode that works with the file system. Use it to save files after editing them.
Command Mode The initial vim mode used when vim is started. It has commands that cut and peplace text, and it is the mode vi uses to enter other modes.

Command line mode The mode that works with the file system. Use it to save files after editing them.

Edit Mode The Mode that vi uses to write and edit text in the file
While in command mode, you copied a whole line of text to memory. You navigated to a different location in the file, and now you need to place the line of text. What command should you use?
p
Match the command on the left with the description on the right to vavigate while in vi command mode.
h Move the cursor up a line.
j Move the cursor one space to the left.
k Move the cursor one space to the right.
l Move the cursor down a line.
Move the cursor up a line. k
Move the cursor one space to the left. h
Move the cursor one space to the right. l
Move the cursor down a line. j
You have opened the /root/myscript file in vi. While looking at the file, your soda spilled, and you hit several keys on the keyboard trying to pick it back up. There are extra characters everywhere in the file, and you know you can'y fix it. How do you exit vi without saving the changes?
:q!
While in command mode, you need to find the term Sam. Which command should you use? (Tip: Enter the command as if in vi command mode.)
/Sam
You need to create a new text file with the name network.txt in the current directory. Which command starts vi and creates the File?
vi network.txt
After opening a file in vi, you want to switch from command mode to command line mode. What key should you use?
:
A friend sent you a shell script file that is 117 lines long. He says that he wants tou to examine code on lines 82 through 87. What command in command line mode takes tou directly to line 82? (Tip: Enter the command as if in comand line mode.)
82
YOU MIGHT ALSO LIKE...