250+ TOP MCQs on Navigation in Vi Editor and Answers

Unix Questions and Answers for Aptitude test on “Navigation in Vi Editor”.

1. We can prefix repeat factor with word navigation commands.
a) True
b) False

Answer: a
Clarification: We can prefix repeat factor with word navigation commands for ease of navigation. For example, 5w takes the cursor 5 words forward while 5b takes the cursor 5 words backwards.

2. Which command is used for moving the cursor to the line extreme?
a) |, 0
b) &
c) %
d) L

Answer: a
Clarification: For moving the cursor to the beginning or end of the line we can use line extreme navigation commands (0,| and $). ‘|’ or ‘0’ moves the cursor to the first character of a line.

3. ____ command moves the cursor to the end of next line.
a) 0
b) |
c) %
d) $

Answer: d
Clarification: ‘$’ command is used to navigate the cursor to the end of next line. This symbol is also used in ex-mode to represent the last line.

4. Which of the following commands will move the cursor to the end of line number 30 if the current position of the cursor is line number 01?
a) 30$
b) 30|
c) 30b
d) 30%

Answer: a
Clarification: We can prefix the repeat factor while working with line extreme navigation commands.

5. Which of the following control keys will be used for scrolling one page forward?
a) ctrl-f
b) ctrl-b
c) ctrl-z
d) ctrl-v

Answer: a
Clarification: Faster navigation can be achieved in vi using control keys for scrolling text in the window page by page. Ctrl-b scrolls one page backwards.

6. We can scroll halve page using control keys.
a) True
b) False

Answer: a
Clarification: To scroll half a page we can use control keys like ctrl-d and ctrl-u.

Ctrl-d  - scrolls half page forward
Ctrl-u  - scrolls Half page backwards

7. To navigate 20 pages forward, we can use ______ command.
a) 20 ctrl-b
b) 20 ctrl-d
c) 20 ctrl-u
d) 20 ctrl-f

Answer: d
Clarification: To navigate through 20 pages simultaneously we can prefix the repeat factor with control keys.

8. Which command is used to know the current line number?
a) ctrl-f
b) ctrl-b
c) ctrl-z
d) ctrl-g

Answer: d
Clarification: At any time, to know the current line number we can use ctrl-g.

9. Which key is used for absolute movement?
a) f
b) G
c) M
d) ctrl-g

Answer: c
Clarification: For absolute movement, we can use the ‘G’ command along with the prefix factor to locate offending lines. For example,

42G    // goes to line number 40
1G    // goes to line number 1
G    // goes to end of file

10. Which of the following commands of ex-mode is equivalent to ‘G’ command in command mode?
a) : .
b) : $
c) : %
d) :w

Answer: b
Clarification: ex-mode offers equivalent commands for moving between lines. ‘G’ command moves the cursor to end of the file which can also be achieved using ‘: $’ command in ex-mode.

Leave a Reply

Your email address will not be published. Required fields are marked *