Editor of God-vim

Source: Internet
Author: User

About VI

VI is the abbreviation of "Visual interface", its status on Linux as if the edit program on DOS. It can perform many text operations, such as output, delete, find, replace, block operations, and so on, and users can customize them according to their own needs. VI is not a typesetting program, it is not like word or WPS can be the font, format, paragraph and other properties of the orchestration, it is just a text editing program. VI There are no menus, only commands, and commands are numerous.

Vi有三种基本工作模式:+  命令模式+  文本输入模式+  末行模式

Command-line mode

At any time, no matter what mode the user is in, just click the ESC key to get VI into the command mode; we enter the Launch VI command under the shell environment (prompt $), which is also in this mode when you enter the editor. In this mode, users can enter a variety of legal VI commands for managing their own documents. Any character entered from the keyboard is interpreted as an edit command, and if the input character is a valid VI command, VI completes the corresponding action after accepting the user command. Note, however, that the commands you enter are not displayed on the screen. If the input character is not a legal command of VI, VI will ring the alarm.

Text input mode

Enter in command mode

    • Insert command I,
    • Additional commands A,
    • Open command O,
    • Modify Command C,
    • Replace command R,
    • Replace command S,

Can enter text input mode. In this mode, any characters entered by the user are saved by VI as the contents of the file and displayed on the screen. In the text input process, if you want to return to the command mode, press ESC.

Last-line mode

The last line mode is also known as ex escape mode. In command mode, the user presses the ":" Key to enter the last row mode, at which time VI displays a ":" As a prompt in the final row of the display window (usually the last line of the screen), waiting for the user to enter a command. Most file management commands are executed in this mode (such as writing the contents of the edit buffer to a file medium). After the last command is executed, VI automatically returns to the command mode. For example:

:sp newfile

A window is edited to edit the NewFile file. If you want to convert from command mode to edit mode, you can type command a or I, and if you need to return from text mode, press ESC. Enter ":" in command mode to switch to the last line mode and enter the command.

Vim Base operation

Vim is a text editor developed from VI. Code completion, compilation and error jump and other convenient programming features are particularly rich

Enter insert mode:

    • i: 插入光标前一个字符
    • I: 插入行首
    • a: 插入光标后一个字符
    • A: 插入行未
    • o: 向下新开一行,插入行首
    • O: 向上新开一行,插入行首

Enter Command mode:

ESC: Enter command mode from insert mode or last line mode

To move the cursor:

  • h: 左移
  • j: 下移
  • k: 上移
  • l: 右移
  • M: 光标移动到中间行
  • L: 光标移动到屏幕最后一行行首
  • G: 移动到指定行,行号 -G
  • w: 向后一次移动一个字
  • b: 向前一次移动一个字
  • {: 按段移动,上移
  • }: 按段移动,下移
  • Ctr-d: 向下翻半屏
  • Ctr-u: 向上翻半屏
  • Ctr-f: 向下翻一屏
  • Ctr-b: 向上翻一屏
  • gg: 光标移动文件开头
  • G: 光标移动到文件末尾

Delete command:

    • x: 删除光标后一个字符,相当于 Del
    • X: 删除光标前一个字符,相当于 Backspace
    • dd: 删除光标所在行,n dd 删除指定的行数 D: 删除光标后本行所有内容,包含光标所在字符
    • d0: 删除光标前本行所有内容,不包含光标所在字符
    • dw: 删除光标开始位置的字,包含光标所在字符

Undo command:

    • u: 一步一步撤销
    • Ctr-r: 反撤销

Repeat command:

    • .: 重复上一次操作的命令

Text line movement:

    • >>: 文本行右移
    • <<: 文本行左移

Copy and paste:

    • yy: 复制当前行,n yy 复制 n 行
    • p: 在光标所在位置向下新开辟一行,粘贴

Visual mode:

    • v: 按字符移动,选中文本
    • V: 按行移动,选中文本可视模式可以配合 d, y, >>, << 实现对文本块的删除,复制,左右移动

Replace operation:

    • r: 替换当前字符
    • R: 替换当前行光标后的字符

Find command:

    • /: str查找
    • n: 下一个
    • N:上一个

Replace command:

Replace all ABC with 123

    • 末行模式下,将当前文件中的所有abc替换成123:%s/abc/123/g
    • 末行模式下,将第一行至第10行之间的abc替换成123:1, 10s/abc/123/g

In Vim, execute the shell command:

末行模式里输入!,后面跟命令

Editor of God-vim

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.