Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
Which command is used to start the vi editor and open a file named notes.txt?
Not quite. Try another option.
Answer: vi notes.txt
The syntax vi filename launches the vi editor with the specified file. If the file does not exist, vi creates a new empty buffer with that name.
Question 2 of 60 · starting vi · Easy
When vi first opens a file, which mode is it in by default?
Not quite. Try another option.
Answer: Command mode
vi always starts in Command (normal) mode, where keystrokes are interpreted as editing commands rather than text input.
Question 3 of 60 · starting vi · Easy
Which key is pressed to switch from Command mode to Insert mode in vi?
Not quite. Try another option.
Answer: i
Pressing i enters Insert mode, allowing you to type text before the cursor position.
Question 4 of 60 · Navigation Commands · Easy
In vi Command mode, which key moves the cursor one character to the right?
Not quite. Try another option.
Answer: l
The l key moves the cursor right by one character. The keys h, j, k, l move left, down, up, and right respectively.
Question 5 of 60 · Navigation Commands · Easy
Which key moves the cursor down one line in vi Command mode?
Not quite. Try another option.
Answer: j
The j key moves the cursor down one line, while k moves it up one line.
Question 6 of 60 · Navigation Commands · Easy
Which command moves the cursor to the beginning of the current line?
Not quite. Try another option.
Answer: 0 (zero)
Pressing 0 (the number zero) moves the cursor to the first character of the current line.
Question 7 of 60 · Navigation Commands · Easy
Which command moves the cursor to the end of the current line in vi?
Not quite. Try another option.
Answer: $
The $ command moves the cursor to the last character of the current line.
Question 8 of 60 · Navigation Commands · Easy
Which command moves the cursor to the last line of the file?
Not quite. Try another option.
Answer: G
Pressing G (capital G) jumps the cursor to the last line of the file, while gg jumps to the first line.
Question 9 of 60 · Scrolling Commands · Easy
Which command scrolls the screen forward by one full page in vi?
Not quite. Try another option.
Answer: Ctrl + f
Ctrl + f scrolls forward (down) one full screen, while Ctrl + b scrolls backward (up) one full screen.
Question 10 of 60 · Scrolling Commands · Easy
Which command scrolls the screen backward by one full page?
Not quite. Try another option.
Answer: Ctrl + b
Ctrl + b scrolls the display backward (up) by one full screen.
Question 11 of 60 · Scrolling Commands · Easy
Which command scrolls the screen down by half a page?
Not quite. Try another option.
Answer: Ctrl + d
Ctrl + d scrolls down by half a screen, while Ctrl + u scrolls up by half a screen.
Question 12 of 60 · Insert and Edit Commands · Easy
Which command appends text after the current cursor position?
Not quite. Try another option.
Answer: a
The a command enters Insert mode and places text after the current cursor position, whereas i inserts before the cursor.
Question 13 of 60 · Insert and Edit Commands · Easy
Which command opens a new line below the current line and enters Insert mode?
Not quite. Try another option.
Answer: o
The lowercase o opens a new line below the current line and switches to Insert mode; uppercase O opens a line above.
Question 14 of 60 · Insert and Edit Commands · Easy
Which command replaces a single character under the cursor with a new one?
Not quite. Try another option.
Answer: r
The r command replaces exactly one character under the cursor with the next key you press, without entering Insert mode.
Question 15 of 60 · Insert and Edit Commands · Easy
Which key is used to return from Insert mode back to Command mode?
Not quite. Try another option.
Answer: Esc
Pressing the Esc key exits Insert mode and returns to Command mode in vi.
Question 16 of 60 · Delete Commands · Easy
Which command deletes the single character under the cursor?
Not quite. Try another option.
Answer: x
The x command deletes the character currently under the cursor.
Question 17 of 60 · Delete Commands · Easy
Which command deletes the entire current line in vi?
Not quite. Try another option.
Answer: dd
The dd command deletes the whole line on which the cursor is placed.
Question 18 of 60 · Delete Commands · Easy
Which command deletes from the cursor to the end of the current word?
Not quite. Try another option.
Answer: dw
The dw command deletes text from the cursor position up to the beginning of the next word.
Question 19 of 60 · Copy-Paste Operations · Easy
Which command copies (yanks) the current line in vi?
Not quite. Try another option.
Answer: yy
The yy command yanks (copies) the entire current line into the buffer for later pasting.
Question 20 of 60 · Copy-Paste Operations · Easy
Which command pastes copied text after the cursor or below the current line?
Not quite. Try another option.
Answer: p
The lowercase p command pastes the yanked or deleted text after the cursor, or below the current line for whole-line yanks.
Question 21 of 60 · starting vi · Medium
You want to open the file report.txt in vi and place the cursor directly on line 25 as soon as the file opens. Which command achieves this?
Not quite. Try another option.
Answer: vi +25 report.txt
The +n option opens the file and positions the cursor at line n. So vi +25 report.txt opens the file at line 25.
Question 22 of 60 · starting vi · Medium
A developer runs vi +/main program.c. What is the effect of this command?
Not quite. Try another option.
Answer: Opens the file with the cursor on the first line containing main
The +/pattern option opens the file and places the cursor on the first occurrence of the given pattern, here the word main.
Question 23 of 60 · starting vi · Medium
You accidentally opened an important system file and want to ensure you cannot modify it while viewing. Which command opens the file in read-only mode?
Not quite. Try another option.
Answer: view filename
Invoking vi as view filename (equivalent to vi -R filename) opens the file in read-only mode, preventing accidental modification.
Question 24 of 60 · Navigation Commands · Medium
The cursor is in the middle of a line. Pressing $ followed by 0 produces what result?
Not quite. Try another option.
Answer: Cursor moves to end of line, then to the beginning of the line
$ moves the cursor to the end of the current line and 0 (zero) moves it to the first character of the line.
Question 25 of 60 · Navigation Commands · Medium
In a 100-line file, which command moves the cursor directly to the last line of the file?
Not quite. Try another option.
Answer: G
G without a count moves the cursor to the last line of the file. 1G or gg go to the first line, and L goes to the bottom of the visible screen.
Question 26 of 60 · Navigation Commands · Medium
The cursor is at the start of the sentence The quick brown fox. You press w three times. On which word does the cursor land?
Not quite. Try another option.
Answer: fox
w moves forward one word each time. Starting at The, three presses move past quick, brown, landing on fox.
Question 27 of 60 · Navigation Commands · Medium
Which command moves the cursor to the matching parenthesis, brace, or bracket of the one under the cursor?
Not quite. Try another option.
Answer: %
The % command jumps between matching pairs of (), {}, or [], which is very useful for checking balanced brackets in code.
Question 28 of 60 · Scrolling Commands · Medium
While editing a large file in command mode, you press Ctrl+f. What happens?
Not quite. Try another option.
Answer: The screen scrolls forward one full page
Ctrl+f scrolls forward (down) by one full screen. Ctrl+d scrolls half a screen, and Ctrl+b scrolls back a full screen.
Question 29 of 60 · Scrolling Commands · Medium
You want to scroll the display down by half a screen while keeping the cursor context. Which key combination should you use?
Not quite. Try another option.
Answer: Ctrl+d
Ctrl+d scrolls down half a screen. Ctrl+u scrolls up half a screen, while Ctrl+f and Ctrl+b move a full screen.
Question 30 of 60 · Scrolling Commands · Medium
What is the difference between Ctrl+u and Ctrl+b in vi?
Not quite. Try another option.
Answer: Ctrl+u scrolls up half a screen; Ctrl+b scrolls up a full screen
Ctrl+u scrolls up (backward) by half a screen, whereas Ctrl+b scrolls up by one full screen.
Question 31 of 60 · Insert and Edit Commands · Medium
The cursor is on a character in the middle of a line. You press A. Where does insertion begin?
Not quite. Try another option.
Answer: At the end of the current line
A appends text at the end of the current line and switches to insert mode, unlike a which appends right after the cursor.
Question 32 of 60 · Insert and Edit Commands · Medium
You want to open a new empty line above the current line and start typing on it. Which command should you use?
Not quite. Try another option.
Answer: O
Uppercase O opens a new line above the current line and enters insert mode. Lowercase o opens a line below.
Question 33 of 60 · Insert and Edit Commands · Medium
The cursor is on the letter t in the word cat. You press r and then p. What is the resulting word?
Not quite. Try another option.
Answer: cap
r replaces the single character under the cursor with the next typed character. Replacing t with p turns cat into cap.
Question 34 of 60 · Insert and Edit Commands · Medium
Which command changes text from the cursor position to the end of the current line, entering insert mode?
Not quite. Try another option.
Answer: C
C is equivalent to c$; it deletes text from the cursor to the end of the line and enters insert mode. cc changes the entire line.
Question 35 of 60 · Delete Commands · Medium
The cursor is at the beginning of a line. You type 3dd. What is the result?
Not quite. Try another option.
Answer: Deletes 3 lines starting from the current line
dd deletes a whole line; prefixing it with a count 3 deletes 3 lines starting at the current line.
Question 36 of 60 · Delete Commands · Medium
The cursor is on the first letter of the word hello. Which command deletes the word including the space after it?
Not quite. Try another option.
Answer: dw
dw deletes from the cursor to the start of the next word, including the trailing space. de deletes to the end of the word but leaves the space.
Question 37 of 60 · Delete Commands · Medium
What does the command d$ do?
Not quite. Try another option.
Answer: Deletes from the cursor to the end of the line
d$ (equivalent to D) deletes all characters from the cursor position to the end of the current line.
Question 38 of 60 · Copy-Paste Operations · Medium
You type 4yy and then move the cursor and press p. What was copied and pasted?
Not quite. Try another option.
Answer: 4 lines were copied and pasted below the cursor line
yy yanks (copies) a line; 4yy yanks 4 lines. p pastes the yanked lines below the current line.
Question 39 of 60 · Copy-Paste Operations · Medium
After yanking a single line with yy, you press P (uppercase). Where is the line pasted?
Not quite. Try another option.
Answer: Above the current line
Uppercase P pastes the yanked content above the current line, whereas lowercase p pastes it below.
Question 40 of 60 · Save and Exit Operations · Medium
You have made changes but decide to discard them and quit vi without saving. Which command should you use?
Not quite. Try another option.
Answer: :q!
:q! quits vi forcefully, discarding all unsaved changes. :wq, :x, and ZZ all save changes before quitting.
Question 41 of 60 · starting vi · Hard
A user runs vi +/main prog.c. What is the intended effect when the file opens?
Not quite. Try another option.
Answer: The cursor is placed on the first line containing the pattern main
vi +/pattern file opens the file and positions the cursor at the first line matching pattern. Here main is the search pattern, so the cursor lands on the first main occurrence.
Question 42 of 60 · starting vi · Hard
You execute vi -R notes.txt. Later you make edits and try :wq. What happens?
Not quite. Try another option.
Answer: vi refuses the write because the file was opened read-only, requiring :wq! to override
The -R flag opens the file in read-only mode. Attempting :wq triggers a warning about read-only status; you must force the write with :wq!.
Question 43 of 60 · starting vi · Hard
What is the difference between launching vi file1 file2 versus vi -o file1 file2 in vim-compatible editors?
Not quite. Try another option.
Answer: -o opens both files in horizontally split windows simultaneously, while the plain form loads them into the buffer list one at a time
Without -o, files are placed in the buffer list and you switch with :n. With -o, both open at once in horizontal splits, visible together.
Question 44 of 60 · Navigation Commands · Hard
The cursor is at the start of a line reading foo_bar baz-qux. In command mode you press w twice. Where does the cursor land?
Not quite. Try another option.
Answer: On baz (the word after the space)
w moves to the next word start. foo_bar is one word (underscore is a word char). First w → baz... wait, first w moves to baz. Since underscore keeps foo_bar as one word, one w reaches baz; the second w reaches the - punctuation. However baz-qux splits at punctuation, so from foo_bar first w→baz, second w→-. The landing after two presses is the -.
Question 45 of 60 · Navigation Commands · Hard
You are on line 50 of a 200-line file. You type 35G. What is the result?
Not quite. Try another option.
Answer: The cursor moves to line 35
nG jumps to absolute line number n. So 35G moves the cursor directly to line 35 regardless of the current position.
Question 46 of 60 · Navigation Commands · Hard
In command mode, what is the key difference between 0, ^, and $?
Not quite. Try another option.
Answer: 0 moves to the very first column, ^ moves to the first non-blank character, and $ moves to the end of the line
0 always goes to column one, ^ goes to the first non-whitespace character of the line, and $ goes to the line's end. These are distinct line-position motions.
Question 47 of 60 · Navigation Commands · Hard
Which command places the cursor on the matching bracket of the one currently under it?
Not quite. Try another option.
Answer: %
% jumps between matching pairs of brackets (), {}, and []. It is commonly used to check balanced parentheses in code.
Question 48 of 60 · Scrolling Commands · Hard
What is the precise difference between Ctrl-f and Ctrl-d while scrolling in vi?
Not quite. Try another option.
Answer: Ctrl-f scrolls forward a full screen, while Ctrl-d scrolls down half a screen
Ctrl-f advances a whole page forward; Ctrl-d scrolls down by half a screen. The 'f' stands for full-page forward and 'd' for down half-page.
Question 49 of 60 · Scrolling Commands · Hard
The cursor is somewhere in the middle of the screen. You press zz. What happens?
Not quite. Try another option.
Answer: The current line is redrawn to the center of the screen without moving the cursor to a different line
zz recenters the display so the current line sits in the middle of the screen. Note ZZ (uppercase) instead saves and exits — a common confusion.
Question 50 of 60 · Scrolling Commands · Hard
Which pair correctly maps the scroll commands Ctrl-e and Ctrl-y?
Not quite. Try another option.
Answer: Ctrl-e scrolls the window down one line, Ctrl-y scrolls up one line, both keeping the cursor on the same text line when possible
Ctrl-e scrolls the view down by a single line and Ctrl-y scrolls up by a single line, without necessarily moving the cursor's line unless it would leave the screen.
Question 51 of 60 · Insert and Edit Commands · Hard
The cursor is on the last non-blank character of an indented line. You want to start typing after that character but at the true end of the line's content. Which single command is correct and efficient?
Not quite. Try another option.
Answer: A
A appends at the end of the current line regardless of cursor column. a appends only after the current character; I inserts at the first non-blank; o opens a new line below.
Question 52 of 60 · Insert and Edit Commands · Hard
In command mode you press 3o and type test, then press Esc. What is the result?
Not quite. Try another option.
Answer: Three new lines each containing test are opened below the current line
A count before o repeats the whole insert. 3o opens a line and, after Esc, replicates the inserted text into three separate new lines below.
Question 53 of 60 · Insert and Edit Commands · Hard
What is the difference between r and R in command mode?
Not quite. Try another option.
Answer: r replaces a single character and returns to command mode, while R enters replace mode overwriting characters until Esc
r replaces exactly one character with the next key pressed, then stays in command mode. R starts overwrite (replace) mode, overwriting successive characters until you press Esc.
Question 54 of 60 · Insert and Edit Commands · Hard
The cursor is in the middle of the word configuration. You press cw and type set. What is the outcome?
Not quite. Try another option.
Answer: The text from the cursor to the end of the word is replaced with set
cw changes from the cursor position to the end of the current word only. Text before the cursor within the word stays intact; the remainder is replaced by set.
Question 55 of 60 · Delete Commands · Hard
The cursor is at the beginning of a five-line paragraph. You type d3j. How many lines are deleted?
Not quite. Try another option.
Answer: 4 lines (the current line plus the next three)
d3j deletes linewise from the current line down through three j movements. That spans the current line and the next three, totaling 4 lines.
Question 56 of 60 · Delete Commands · Hard
What does d$ accomplish, and how does it differ from D?
Not quite. Try another option.
Answer: They are functionally identical: both delete from the cursor to the end of the line
D is a shorthand for d$; both delete text from the current cursor position through the end of the line, leaving text before the cursor untouched.
Question 57 of 60 · Delete Commands · Hard
You press x five times rapidly. What is the equivalent single command?
Not quite. Try another option.
Answer: 5x
A numeric prefix repeats the command that count of times. 5x deletes five characters starting at the cursor, equivalent to pressing x five times.
Question 58 of 60 · Copy-Paste Operations · Hard
You execute 3yy then move the cursor and press p. What is placed and where?
Not quite. Try another option.
Answer: Three yanked lines are pasted on the lines below the cursor's current line
3yy yanks three whole lines. Because the yank is linewise, p pastes them below the current line (a lowercase p pastes after; P would paste above).
Question 59 of 60 · Copy-Paste Operations · Hard
After deleting a word with dw, you press p. Why does text appear even though you did a delete, not a yank?
Not quite. Try another option.
Answer: Deleted text is stored in the unnamed register, and p pastes from that register just like yanked text
In vi both deletes and yanks fill the unnamed register. So dw places the deleted word there, and p pastes whatever is currently in that register — this enables cut-and-paste.
Question 60 of 60 · Copy-Paste Operations · Hard
You yank a line into named register a using "ayy, then perform several deletes. To paste the originally yanked line, which command works?
Not quite. Try another option.
Answer: "ap
Naming the register with "a preserves the yank separately from the unnamed register. Subsequent deletes overwrite only the unnamed register, so "ap pastes the safely stored line from register a.
That's unit 9
Answer a few questions and your score shows up here.
Nearly through. Did unit 9 of CSE105 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 9 of CSE105 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.