Vim Editor Commands Quiz

TalentedParabola avatar
TalentedParabola
·
·
Download

Start Quiz

Study Flashcards

30 Questions

What command in Vim editor moves the cursor to the top of the page?

M

In Vim editor, which command moves the cursor to the end of a line?

$

Which command in Vim editor scrolls back one page?

CTRL + b

What command in Vim editor moves the cursor to the beginning of the next sentence?

)

Which command in Vim editor moves the cursor one word at a time?

$

In Vim editor, what command moves the cursor back a word at a time?

B

How can a user toggle back to the command mode from the last line mode in Vim editor?

By pressing the ESC key twice

What is the correct method to create a file in Vim editor?

Type vi followed by a file name and press Enter key

Which command is used to enter insert mode in Vim editor?

None of the above

How can a file be saved in Vim editor?

:wq

Which key is pressed twice to toggle back to the command mode from the last line mode in Vim editor?

[Delete]

What happens when 'vi' is typed without a file name in Vim editor?

'vi' command opens a new unsaved buffer for editing

To execute Linux commands from within the Vim editor, what symbol should be typed before the command?

! (exclamation)

What is the purpose of a shell script in Linux?

To execute a set of commands in a controlled order

Which of the following is NOT a common element in a shell script?

Blocks

In Linux, what is a good practice regarding file extensions for shell scripts?

It is good practice to use .sh extension

What distinguishes a shell script from single Linux commands?

A shell script is a set of commands written in plain text file that performs a designated task in a controlled order

What is the main benefit of using shell scripts in Linux?

To make system operations more efficient by automating tasks

What symbol signifies the beginning of a comment in Ubuntu Linux?

What type of elements in a script are not executed but provide understanding to users?

Comment

Which command clears the screen contents before displaying the output of a script?

Clear

Which command is used to display a message on the screen?

Echo

What command provides the name and additional details of the currently logged-in user?

who am i

Which command is used to execute a script using 'sh' or 'bash' command?

Both (a) and (b)

Should there be a space before and after the assignment operator (=) when writing a numerical expression in Linux?

No

In Linux, which operator is used for addition?

Which operator is used for subtraction in Linux?

What operator is used for multiplication in Linux?

**

Which operator is used for division in Linux?

/

What happens if there is a tie between operators of the same priority in a numerical expression?

First one is executed

Study Notes

Vim Editor

  • In the Vim editor, a colon character is seen at the beginning of the last line of the window with the cursor blinking near it.
  • Pressing the ESC key twice toggles back to command mode from the last line mode.

Creating a File in Vim Editor

  • A file can be created in Vim editor by typing "vi" followed by a file name and pressing Enter, or by simply typing "vi" and pressing Enter.
  • The commands used to create a file in Vim editor are both "vi filename" and "vi".

Insert Mode

  • The commands used to enter insert mode are both "a" and "i".

Saving a File

  • The command used to save a file in Vim editor is ":s/phrasel/phrase2".

Executing Linux Commands in Vim Editor

  • To execute Linux commands from within the Vim editor, type an exclamation mark (!) before the command.

Shell Scripts

  • A shell script is a set of commands written in plain text that performs a designated task in a controlled order.
  • It is not necessary to provide a ".sh" extension to a shell script, but it is a good practice to do so.

Operators in Linux

  • The operators used for basic arithmetic operations in Linux are:
    • Addition: +
    • Subtraction: -
    • Multiplication: *
    • Division: /
    • Modulus (remainder): %

Numerical Expressions in Linux

  • Numerical expressions in Linux are evaluated according to the general norms of mathematics.
  • In case of a tie between operators of the same priority, preference is given to the operator that occurs first.
  • To force one operation to be performed earlier than another, the operation can be enclosed in parentheses.

Vim Editor Navigation

  • The commands used to navigate in Vim editor are:
    • CTRL + b: scrolls back one page
    • M: moves the cursor to the middle of the page
    • H: moves the cursor to the top of the page
    • L: moves the cursor to the bottom of the page
    • $: moves the cursor to the end of the line
    • ): moves the cursor to the beginning of the next sentence
    • (: moves the cursor to the beginning of the current sentence
    • G: moves the cursor to the end of the file
    • W: moves the cursor one word at a time
    • B: moves the cursor back a word at a time

Comments in Ubuntu Linux

  • A comment in Ubuntu Linux begins with the symbol #.
  • Comments are not executed; they are messages that help users understand the usage or meaning of the script.

Screen Commands

  • The command used to clear the screen contents before giving the output of the script is "clear".
  • The command used to display a message on the screen is "echo".

User Information

  • The command used to display the name and some additional details of the user currently logged into the system is "who am i".

Executing Scripts

  • The commands used to execute a script are both "sh" and "bash".
  • The command used to set the desired privileges is "chmod".
  • The command used to make a file executable is "chmod +x filename".

Test your knowledge of Vim editor commands and shortcuts with this quiz. See if you can identify which key to press twice to toggle back to the command mode. Identify common prompts and characters in Vim editor windows.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Vim Editor Modes
10 questions

Vim Editor Modes

RationalClearQuartz avatar
RationalClearQuartz
Vim Configuration File Tutorial
20 questions
Vim Editor: Features and Usage
10 questions
Vim Text Editing Commands Quiz
28 questions
Use Quizgecko on...
Browser
Browser