VIM Editor Operation Guide
vim [参数] [文件 ..] 编辑指定的文件 或: vim [参数] - 从标准输入(stdin)读取文本 或: vim [参数] -t tag 编辑 tag 定义处的文件 或: vim [参数] -q [errorfile] 编辑第一个出错处的文件
-- 在这以后只有文件名 -v Vi 模式 (同 "vi") -e Ex 模式 (同 "ex") -E Improved Ex mode -s 安静(批处理)模式 (只能与 "ex" 一起使用) -d Diff 模式 (同 "vimdiff") -y 容易模式 (同 "evim",无模式) -R 只读模式 (同 "view") -Z 限制模式 (同 "rvim") -m 不可修改(写入文件) -M 文本不可修改 -b 二进制模式 -l Lisp 模式 -C 兼容传统的 Vi: 'compatible' -N 不完全兼容传统的 Vi: 'nocompatible' -V[N][fname] Be verbose [level N] [log messages to fname] -D 调试模式 -n 不使用交换文件,只使用内存 -r 列出交换文件并退出 -r(跟文件名) 恢复崩溃的会话 -L 同 -r -A 以 Arabic 模式启动 -H 以 Hebrew 模式启动 -F 以 Farsi 模式启动 -T 设定终端类型为 --not-a-term Skip warning for input/output not being a terminal -u 使用 替代任何 .vimrc --noplugin 不加载 plugin 脚本 -P[N] 打开 N 个标签页 (默认值: 每个文件一个) -o[N] 打开 N 个窗口 (默认值: 每个文件一个) -O[N] 同 -o 但垂直分割 + 启动后跳到文件末尾 + 启动后跳到第 行 --cmd <command></command> 加载任何 vimrc 文件前执行 <command></command> -c <command></command> 加载第一个文件后执行 <command></command> -S 加载第一个文件后执行文件 <command></command> -s 从文件 读入正常模式的命令 <command></command> -w 将所有输入的命令追加到文件 <command></command> -W 将所有输入的命令写入到文件 <command></command> -x 编辑加密的文件 <command></command> --startuptime Write startup timing messages to <command></command> -i 使用 取代 .viminfo <command></command> -h 或 --help 打印帮助(本信息)并退出 <command></command> --version 打印版本信息并退出
Vi has three basic working modes:
At any time, no matter what mode the user is in, just press the ESC key to enter Vi into the command mode; when we enter the start Vi command in the shell environment (the prompt is $), when entering the editor, we are also in in this mode. In this mode, users can enter various legal Vi commands to manage their own documents. At this time, any character entered from the keyboard is interpreted as an editing command. If the entered character is a legal Vi command, Vi completes the corresponding action after accepting the user command. However, it should be noted that the entered commands are not displayed on the screen. If the characters entered are not legal commands for Vi, Vi will ring the alarm.
In command mode, enter the insert command i, append command a, open command o, modify command c, replace command r or replace command s to enter text input mode. In this mode, any characters entered by the user are saved by Vi as file content and displayed on the screen. During the text input process, if you want to return to the command mode, just press the ESC key.
Last line mode is also called ex escape mode. In command mode, the user presses the ":" key to enter the last line mode. At this time, Vi will display a ":" on the last line of the display window (usually the last line of the screen) as the prompt for the last line mode. Wait 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, etc.). After the last command line is executed, Vi automatically returns to command mode. For example:
:sp newfile
will separate a window to edit the newfile file. If you want to switch from command mode to edit mode, you can type the command a or i; if you need to return from text mode, just press the Esc key. Enter ":" in command mode to switch to last line mode, and then enter the command.
Enter insert mode:
i: 插入光标前一个字符 I: 插入行首 a: 插入光标后一个字符 A: 插入行未 o: 向下新开一行,插入行首 O: 向上新开一行,插入行首
Enter command mode:
ESC:从插入模式或末行模式进入命令模式 移动光标: 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: 删除光标开始位置的字,包含光标所在字符
Cancel command:
u: 一步一步撤销 Ctr-r: 反撤销
Repeat command:
.: 重复上一次操作的命令 文本行移动: >>: 文本行右移 <<: 文本行左移 复制粘贴: yy: 复制当前行,n yy 复制 n 行 p: 在光标所在位置向下新开辟一行,粘贴 可视模式: v: 按字符移动,选中文本 V: 按行移动,选中文本可视模式可以配合 d, y, >>, << 实现对文本块的删除,复制,左右移动 替换操作: r: 替换当前字符 R: 替换当前行光标后的字符 查找命令: /: str查找 n: 下一个 N:上一个
Replace command:
把abc全部替换成123 末行模式下,将当前文件中的所有abc替换成123 :%s/abc/123/g 末行模式下,将第一行至第10行之间的abc替换成123 :1, 10s/abc/123/g vim里执行 shell 下命令: 末行模式里输入!,后面跟命令
The above is the detailed content of VIM Editor Operation Guide. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

How to run Python scripts in Sublime Text: Install Python interpreter configuration Interpreter path in Sublime Text Press Ctrl B (Windows/Linux) or Cmd B (macOS) to run the script If an interactive console is required, press Ctrl \ (Windows/Linux) or Cmd \ (macOS)
