96.
How would you remove two lines of text from a file using Vi?
- A.In command mode, position the cursor on the first line, and type 2dd.
- B.In command mode, position the cursor on the last line, and type 2yy.
- C.In insert mode, position the cursor at the start of the first line, hold down the Shift key while pressing the Down arrow key twice, and press the Delete key on the keyboard.
- D.In insert mode, position the cursor at the start of the first line, and press Ctrl+K twice.
- E.Using your mouse, select both lines, and then press the Delete or Backspace key.
- Answer & Explanation
- Report
Answer : [A]
Explanation :
Explanation :
In Vi, dd is the command-mode command that deletes lines. Preceding this command by a number deletes that number of lines. Thus, option A is correct. Although yy works similarly, it copies (yanks) text rather than deleting it, so option B is incorrect. Option C works in many more modern text editors, but not in Vi. Option D works in Emacs and similar text editors, but not in Vi. Option E works in many GUI text editors, but not in Vi. |
97.
In Vi’s command mode, you type :q!. What is the effect?
- A.Nothing; this isn’t a valid Vi command.
- B.The text :q! is inserted into the file you’re editing.
- C.The program terminates and saves any existing files that are in memory.
- D.The program terminates without saving your work.
- E.An exclamation point (!) overwrites the character under the cursor in the text.
- Answer & Explanation
- Report
Answer : [D]
Explanation :
Explanation :
The :q! Vi command does as option D states. Options A and E are both simply incorrect. Option B would be correct if this command were typed while in Vi’s insert mode, but the question specifies that command mode is in use. To achieve option C, the command would be :wq, not :q!. |
98.
What is an advantage of Vi over Emacs?
- A.Vi is X-based and so is easier to use than Emacs.
- B.Vi encodes text in EBCDIC, which is more flexible than Emacs’ ASCII.
- C.Vi’s mode-based operations permit it to handle non-English languages
- D.Vi includes a built-in Web browser and email client; Emacs doesn’t.
- E.Vi is smaller and so can fit on compact emergency systems and embedded devices.
- Answer & Explanation
- Report
Answer : [E]
Explanation :
Explanation :
Vi is included on Linux emergency disks, embedded systems, and other systems where space is at a premium because its executable is tiny. Emacs is, in contrast, a behemoth. Thus, option E is correct. Contrary to option A, Vi isn’t an X-based program (although X-based Vi variants are available); Emacs can be used in text mode or with X. Extended Binary Coded Decimal Interchange Code (EBCDIC) is an obscure 8-bit character encoding system used on some very old mainframe OSs. When run on Linux, Vi doesn’t use EBCDIC; furthermore, EBCDIC offers few or no advantages over the American Standard Code for Information Interchange (ASCII). Thus, option B is incorrect. Vi’s modes, referred to in option C, have nothing to do with non-English language support. Option D is backward; it’s Emacs that includes a Web browser, email client, and other add-ons. |
99.
From Vi’s command mode, you want to enter insert mode. How might you do this?
(Select three.)
- A.Type R.
- B.Type i.
- C.Type a.
- D.Type :.
- E.Press Esc.
- Answer & Explanation
- Report
Answer : [A, B, C]
Explanation :
Explanation :
Typing R (option A) in command mode enters insert mode with the system configured to overwrite existing text. Typing i or a (options B and C, respectively) enters insert mode with the system configured to insert text. (The i and a commands differ in how they place the cursor; a advances one space.) Typing : (option D) in command mode enters ex mode (you typically type the ex-mode command on the same command line immediately after the colon). Pressing the Esc key (option E) returns Vi to command mode from insert mode. |
100.
How do you exit Vi’s insert mode in order to type command-mode commands?
- A.Press the ~ key.
- B.Press the Esc key.
- C.Type Ctrl+X followed by Ctrl+C.
- D.Press the F10 key.
- E.Press the Shift+Insert key combination
- Answer & Explanation
- Report
Answer : [B]
Explanation :
Explanation :
The Esc key exits Vi’s insert mode, as option B specifies. Typing a tilde (~) inserts that character into the file, so option A is incorrect. The Ctrl+X, Ctrl+C key combination exits from Emacs, but it’s not a defined Vi key sequence, so option C is incorrect. The F10 key and the Shift+Insert key combination also aren’t defined in Vi, so options D and E are both incorrect. |