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

By: Prof. Fazal Rehman Shamil
Last modified on April 22nd, 2021

Solved MCQs of Commands for Searching, Replacing and Substituting in Vi Editor.

An ex-mode command is the Substitution command.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: a


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


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


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


While performing the substitution flag field empty can’t be empty.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: b


For searching a pattern in vi which symbol is used?
(A). /
(B). / and ?
(C). %
(D). ?
(E). None of these
Multiple Choice Question Answer: b


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


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


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


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


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


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


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


The target pattern is always optional.
(A). True
(B). False
(C). Partially True
Multiple Choice Question Answer: a


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