乐闻世界logo
搜索文章和话题

What are the different modes when using the vi editor?

1个答案

1

When using the vi editor, there are primarily three modes:

  1. Normal Mode:

    • This is the default mode after opening a file in vi.
    • In Normal Mode, you can use various keyboard commands to navigate the cursor, delete text, copy and paste content, and so on.
    • For example, using h, j, k, and l moves the cursor left, down, up, and right respectively.
    • Using dd deletes a line, and yw copies a word.
  2. Insert Mode:

    • In Insert Mode, you can directly input text to edit the file.
    • You enter Insert Mode by pressing i in Normal Mode, where any input is added directly to the file.
    • Pressing Esc returns you to Normal Mode from Insert Mode.
    • Other variants include pressing a to enter Insert Mode and start typing after the current cursor position, or pressing o to open a new line below the current line and enter Insert Mode.
  3. Ex Mode or Command-Line Mode:

    • In Ex Mode, you can enter specific commands to save, exit, search, and replace text.
    • You enter Ex Mode by pressing : in Normal Mode.
    • For example, typing :w saves the file, :q exits the editor, :wq saves and exits, and :s/old/new/g performs a global replacement.

By mastering the transitions between and characteristics of these three modes, you can effectively improve efficiency and accuracy when using the vi editor.

2024年8月14日 13:05 回复

你的答案