Unix Questions and Answers – Navigation in Vi Editor – 2

This set of Unix Questions and Answers for Aptitude test focuses on “Navigation in Vi Editor – 2”.

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

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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) $
View Answer

Answer: d
Explanation: ‘$’ 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.
advertisement
advertisement

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%
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: a
Explanation: 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
View Answer

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

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

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

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

Answer: c
Explanation: 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
View Answer

Answer: b
Explanation: 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.

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix for Aptitude test, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.