Make 55 MCQs with answers and concise explanations about using various Vim features,…
- User
Make 55 MCQs with answers and concise explanations about using various Vim features, especially but not only the most important commonly-used features. Each MCQ needs to have at least three different options.
- Assistant
- What command is used to enter Vim's insert mode?
a) :command
b) i
c) v
d) insertAnswer: b) i
Explanation: The 'i' command allows you to enter insert mode, which allows text to be entered into the buffer.- Which command is used to save changes and exit Vim?
a) :command
b) w
c) q
d) xAnswer: c) q
Explanation: The 'q' command is used to quit Vim. If there are unsaved changes, it will prompt to save before quitting.- How do you move to the start of the current line in Vim?
a) 0
b) :start
c) ^
d) homeAnswer: a) 0
Explanation: Pressing '0' (zero) moves the cursor to the start of the current line in Vim.- Which command is used to delete the current line in Vim?
a) :d
b) dd
c) :delete
d) dlAnswer: b) dd
Explanation: The 'dd' command is used to delete the current line in Vim. The cursor can be placed anywhere on the line.- How can you switch between different opened files within Vim?
a) :open
b) :tab
c) :file
d) :bufferAnswer: d) :buffer
Explanation: The ':buffer' command lists all opened files and allows you to switch between them by entering a buffer number.- What command is used to search for a specific word in Vim?
a) /search
b) ?find
c) :query
d) :findAnswer: a) /search
Explanation: Typing '/search' in command mode allows you to search forward for the word 'search' within the current file.- How can you copy the current line in Vim?
a) :copy
b) yy
c) :duplicate
d) ccAnswer: b) yy
Explanation: The 'yy' command is used to copy (yank) the current line in Vim.- Which command is used to move the cursor to the end of the current line?
a) $
b) :end
c) :move_eol
d) eAnswer: a) ' moves the cursor to the end of the current line in Vim.
- How can you undo the last action in Vim?
a) :undo
b) u
c) :revert
d) rrAnswer: b) u
Explanation: Pressing 'u' undoes the last action performed in Vim.- What is the command to insert a new line above the current line in Vim?
a) :new
b) GG
c) :insert
d) OAnswer: d) O
Explanation: Pressing 'O' (capital O) inserts a new line above the current line in Vim.- How can you select and copy multiple lines in Vim?
a) :select
b) yy
c) :copy
d) VAnswer: d) V
Explanation: Pressing 'V' enters visual line mode, allowing you to select and copy multiple lines in Vim.- What command is used to replace a single character under the cursor in Vim?
a) r
b) :replace
c) cc
d) ~Answer: a) r
Explanation: Pressing 'r' allows you to replace a single character under the cursor in Vim.- How can you open a new split window in Vim?
a) :newsplit
b) CTRL+W s
c) :splitwindow
d) SAnswer: b) CTRL+W s
Explanation: Pressing 'CTRL+W' followed by 's' splits the current window vertically, opening a new split window in Vim.- Which command is used to execute a shell command within Vim and display the output?
a) :sh
b) :exec
c) !command
d) :shellAnswer: c) !command
Explanation: Typing '!command' in command mode will execute 'command' using the shell in Vim and display the output.- How can you select and delete multiple words in Vim?
a) :delete
b) dd
c) :cut
d) vAnswer: d) v
Explanation: Pressing 'v' enters visual mode, allowing you to select and delete multiple words in Vim.- Which command is used to navigate multiple lines at once in Vim?
a) j
b) k
c) l
d) mAnswer: a) j
Explanation: Pressing 'j' moves the cursor down one line in Vim. It can be repeated to navigate multiple lines.- How can you mark a specific location within a file in Vim?
a) :mark
b) :bookmark
c) mm
d) maAnswer: d) ma
Explanation: Typing 'ma' in command mode marks the current location with the mark 'a' in Vim.- What command is used to paste the contents of the default register in Vim?
a) :paste
b) :put
c) pp
d) PAnswer: c) pp
Explanation: Pressing 'p' twice pastes the contents of the default register in Vim.- How can you toggle the case of a word in Vim?
a) ~
b) :case
c) cc
d) UAnswer: a) ~
Explanation: Pressing '~' toggles the case of the character or word under the cursor in Vim.- Which command is used to save changes and continue editing in Vim?
a) :save
b) :wq
c) :write
d) :editAnswer: c) :write
Explanation: The ':write' command is used to save changes made in the file while continuing editing in Vim.- How can you move the cursor to the first non-blank character of the current line in Vim?
a) 0
b) :first
c) ^
d) FAnswer: c) ^
Explanation: Pressing '^' moves the cursor to the first non-blank character of the current line in Vim.- What command is used to insert a new line below the current line in Vim?
a) :new
b) gg
c) :insert
d) oAnswer: d) o
Explanation: Pressing 'o' (lowercase O) inserts a new line below the current line in Vim.- How can you select and delete a range of lines in Vim?
a) :delete
b) dd
c) :cut
d) VAnswer: d) V
Explanation: Pressing 'V' enters visual line mode, allowing you to select and delete a range of lines in Vim.- Which command is used to change the case of a word to lowercase in Vim?
a) :tolower
b) :case
c) gu
d) r~Answer: c) gu
Explanation: Typing 'gu' in command mode changes the case of a word to lowercase in Vim.- How can you exit insert mode and return to command mode in Vim?
a) ESC
b) CTRL+I
c) :exit
d) jjAnswer: a) ESC
Explanation: Pressing the 'ESC' key exits insert mode and returns to command mode in Vim.- What command is used to change the case of a word to uppercase in Vim?
a) :toupper
b) :case
c) gU
d) r~Answer: c) gU
Explanation: Typing 'gU' in command mode changes the case of a word to uppercase in Vim.- How can you paste contents from a named register in Vim?
a) :put
b) :paste
c) "+p
d) :yankAnswer: c) "+p
Explanation: The "+p command is used to paste contents from a named register (in this case the system clipboard) in Vim.- Which command is used to navigate to the last line of the current file in Vim?
a) :last
b) :move_bottom
c) G
d) $Answer: c) G
Explanation: Typing 'G' in command mode moves the cursor to the last line of the current file in Vim.- How can you select and replace a range of characters in Vim?
a) :replace
b) xp
c) R
d) vAnswer: d) v
Explanation: Pressing 'v' enters visual mode, allowing you to select a range of characters that can be replaced in Vim.- What command is used to go to a specific line within a file in Vim?
a) :goto
b) :line
c) :jump
d) :#Answer: d) :#
Explanation: Typing ':#' followed by the line number allows you to go directly to that line within a file in Vim.- How can you repeat the last text-editing command in Vim?
a) :repeat
b) .
c) :redo
d) rrAnswer: b) .
Explanation: Pressing the '.' (dot) command repeats the last text-editing command performed in Vim.- Which command is used to replace a range of characters with new text in Vim?
a) :replace
b) x
c) :substitute
d) :replacewithAnswer: c) :substitute
Explanation: The ':substitute' command is used to replace a range of characters with new text in Vim.- How can you select a rectangular block of text in Vim?
a) :block
b) CTRL+V
c) :rect
d) VAnswer: b) CTRL+V
Explanation: Pressing 'CTRL+V' enters visual block mode, allowing you to select a rectangular block of text in Vim.- What command is used to open a new tab in Vim?
a) :opentab
b) :newtab
c) :tabnew
d) TAnswer: c) :tabnew
Explanation: The ':tabnew' command is used to open a new tab in Vim, allowing you to work with multiple files simultaneously.- How can you join multiple lines into a single line in Vim?
a) JJ
b) J
c) :combine
d) :joinAnswer: d) :join
Explanation: The ':join' command is used to join multiple lines into a single line in Vim.- Which command is used to delete a range of lines in Vim?
a) :cut
b) :delete
c) dd
d) dtAnswer: b) :delete
Explanation: The ':delete' command is used to delete a range of lines in Vim. Specify the range before using this command.- How can you repeat a specific motion or text object in Vim?
a) [[
b) U
c) .
d) VAnswer: c) .
Explanation: Pressing the '.' (dot) command repeats the last motion or text object in Vim.- What command is used to search and replace text in Vim?
a) :search
b) rr
c) :substitute
d) :replaceAnswer: c) :substitute
Explanation: The ':substitute' command is used to search and replace text in Vim. It supports regular expressions.- How can you select and change the case of a range of characters in Vim?
a) :toggle
b) v
c) ~
d) VAnswer: d) V
Explanation: Pressing 'V' enters visual line mode, allowing you to select a range of characters to change the case in Vim.- Which command is used to reload the current file in Vim?
a) :load
b) :refresh
c) :reread
d) :edit!Answer: d) :edit!
Explanation: The ':edit!' command reloads the current file, discarding any unsaved changes, in Vim.- How can you navigate to the next occurrence of a word in Vim?
a) /next
b) :searchnext
c) n
d) :findAnswer: c) n
Explanation: Pressing 'n' advances the cursor to the next occurrence of the last searched word in Vim.- What command is used to indent a range of lines in Vim?
a) <<
b) :indent
c) :shift
d) >>Answer: a) <<
Explanation: Typing '<<' in command mode indents a range of lines one level to the left in Vim.- How can you select and replace a range of lines with new text in Vim?
a) :replace
b) :substitute
c) V
d) :changeAnswer: c) V
Explanation: Pressing 'V' enters visual line mode, allowing you to select a range of lines that can be replaced with new text in Vim.- Which command is used to delete a word from the current position in Vim?
a) :worddelete
b) :delete
c) dw
d) deAnswer: c) dw
Explanation: The 'dw' command, when executed from normal mode, deletes from the current position to the end of the current word in Vim.- How can you quickly navigate to the beginning of the next word in Vim?
a) 0
b) :nextword
c) w
d) BAnswer: c) w
Explanation: Pressing 'w' moves the cursor to the beginning of the next word in Vim.- What command is used to find and replace text within a range of lines in Vim?
a) :rangedsubstitute
b) :substitute
c) %s
d) :replaceAnswer: c) %s
Explanation: Typing '%s' followed by the search pattern and replacement text performs a find and replace within a range of lines in Vim.- How can you navigate to the previous occurrence of a word in Vim?
a) /previous
b) :searchprevious
c) N
d) :findAnswer: c) N
Explanation: Pressing 'N' moves the cursor to the previous occurrence of the last searched word in Vim.- Which command is used to join the current line with the next line in Vim?
a) :connect
b) K
c) J
d) :joinAnswer: c) J
Explanation: Typing 'J' in normal mode joins the current line with the next line in Vim.- How can you create a new line above the current line without entering insert mode in Vim?
a) oo
b) :openline
c) O
d) SHIFT+OAnswer: d) SHIFT+O
Explanation: Pressing 'SHIFT+O' creates a new line above the current line without entering insert mode in Vim.- What command is used to copy a range of lines to a specific location within a file in Vim?
a) :copyto
b) :cut
c) :move
d) :putAnswer: c) :move
Explanation: The ':move' command is used to copy a range of lines to a specific location within a file in Vim.- How can you repeat the last search command in Vim?
a) :repeat
b) /
c) :redo
d) /Answer: d) /
Explanation: Pressing '/' followed by 'Enter' repeats the last search command in Vim, searching for the same pattern.- Which command is used to search and replace text within a range of lines in Vim with confirmation?
a) :rangedsubstitute
b) :substitute
c) %s
d) :replaceAnswer: c) %s
Explanation: Typing '%s' followed by the search pattern, replacement text, and 'g' flag performs a find and replace within a range of lines in Vim, prompting for confirmation.- How can you mark the current location and quickly jump back to it later in Vim?
a) :mark
b) CTRL+O
c) m
d) ggAnswer: c) m
Explanation: Typing 'ma' in command mode marks the current location with the mark 'a' in Vim. To jump back, use the 'a' command.- What command is used to align text within a selected visual block in Vim?
a) :align
b) :block
c) :center
d) =Answer: d) =
Explanation: Pressing '=' in normal mode aligns the selected visual block of text in Vim.- How can you switch between multiple open tabs in Vim?
a) :tab
b) :switchtab
c) gt
d) tAnswer: c) gt
Explanation: Pressing 'gt' switches between multiple open tabs in Vim.