This set of Unix Questions and Answers for Campus interviews focuses on “Editing Text in Vi Editor – 2”.
1. We can use ‘yy’ command for copy and paste operation.
Explanation: We can copy lines using ‘yy’ command and paste it at another location using ‘p’ or ‘P’ command.
2. Which command is used for joining lines?
Explanation: To join current line with the line(s) following it, we can use join (J) command. It just pulls up the following line by terminating the new line character between the current line and following line.
3. Which command will be used to join 4 lines with the current line?
Explanation: Join command joins the current line with the following number of lines. For example,
5J // joins current line with following four lines
4. Which of the following undo a most recent single editing change?
Explanation: To reverse the last change you made to the buffer press the ‘u’ key. This will restore the state of the buffer by undoing the most recent action taken.
5. ___ command allows us to undo a number of changes that have been made to a single line before moving away from that line.
Explanation: When a number of changes have to be made to a single line, vi allows us to discard all changes before you move away from the line. If the cursor has been moved to another line before invoking ‘U’, this command will not work.
6. Which command is used to redo the changes made by the undo command?
Explanation: We can use the control key (ctrl-r) to redo the changes which are made by the undo command.
7. ’10u’ command will reverse our 10 last editing actions.
Explanation: We can undo multiple changes using ‘u’ command by prefixing repeat factor with command. For example,
10u // reverses our last 10 editing actions
8. Which symbol is used for repeating the last command?
Explanation: Using (.) operator, we can simply repeat the last command that was used. The principle behind repeat command is, use the actual command once and then repeat it at other places with dot (.) command.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix for Campus Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.