Commands for Searching, Replacing, and Substituting in Vi Editor MCQS

1.An ex-mode command is the Substitution command.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: a
2. For substitution command which command do we use?
(A). n
(B). s
(C). N
(D). S
(E). None of these
Multiple Choice Question Answer: d
3. To replace ‘professor’ with ‘director’ throughout the whole file, which command do we use?
(A). 1,$s/professor/director/g and %s/professor/director/g
(B). %s/professor/director/g
(C). 1,$s/professor/director
(D). 1,$s/professor/director/g
(E). None of these
Multiple Choice Question Answer: a
4. For performing substitution on a file, what is the correct syntax?
(A). :address
(B). :address/target_pattern source_pattern/flag
(C). :address/flag
(D). :address/source_pattern/target_pattern/flag
(E). None of these
Multiple Choice Question Answer: d
5. While performing the substitution flag field empty can’t be empty.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: b
6. For searching a pattern in vi which symbol is used?
(A). /
(B). / and ?
(C). %
(D). ?
(E). None of these
Multiple Choice Question Answer: b
7. For interactive substitution, which flag do we use?
(A). g
(B). gc
(C). G
(D). cg
(E). None of these
Multiple Choice Question Answer: b
8. The regular expressions can be used by Search and replace operations to match multiple patterns.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: a
9. For repeating the search in the same direction which command do we use?
(A). NN
(B). N
(C). nn
(D). n
(E). None of these
Multiple Choice Question Answer: d
10. For deleting all the instances of string ‘manager’ in file003, which command do we use?
(A). %s/manager/ /
(B). %s/manager/director/g
(C). 1,$s/professor/director
(D). 1,$s/manager/ /g
(E). None of these
Multiple Choice Question Answer: d
11. The invalid command is______
(A). /printf
(B). :1,%/file01/file02/g
(C). :%/abd/mash/wc
(D). ?scanf
(E). None of these
Multiple Choice Question Answer: b
12. What searches for the first instance of a pattern in the forward direction?
(A). &
(B). %
(C). /
(D). ?
(E). None of these
Multiple Choice Question Answer: c
14. What searches for the first instance of a pattern in the backward direction?
(A). ?
(B). %
(C). &
(D). /
(E). None of these
Multiple Choice Question Answer: a
15. The target pattern is always optional.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: a
16. To reverse the direction of repeating the search which command do we use?
(A). n
(B). nn
(C). N
(D). NN
(E). None of these
Multiple Choice Question Answer: c