← 返回命令列表

Linux command

vim 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Open a file in vim

vim [file]

Open file at specific line

vim +[line_number] [file]

Open in read-only mode

vim -R [file]

Open multiple files

vim -p [file1] [file2]

Open multiple files

vim -o [file1] [file2]

Open and execute command

vim -c "[command]" [file]

Compare two files

vim -d [file1] [file2]

说明

vim (Vi IMproved) is a highly configurable text editor built for efficient text editing. It extends the classic vi editor with features like syntax highlighting, visual mode, multiple buffers, and extensive plugin support. Vim operates primarily through keyboard commands in different modes, enabling powerful text manipulation without leaving the home row. While the learning curve is steep, proficiency enables very fast editing. Configuration lives in ~/.vimrc (or ~/.vim/vimrc). Plugins can be managed with package managers like vim-plug, Vundle, or native packages (Vim 8+).

参数

+ _line_
Start at specified line number
+ _command_
Execute command after loading file
-c _command_
Execute command after loading file
-R
Read-only mode
-r
Recovery mode (recover from swap file)
-p
Open files in tabs
-o
Open files in horizontal splits
-O
Open files in vertical splits
-d
Diff mode
-b
Binary mode
-x
Edit encrypted file
-u _vimrc_
Use specified vimrc file
-N
Not compatible mode (use Vim defaults)

FAQ

What is the vim command used for?

vim (Vi IMproved) is a highly configurable text editor built for efficient text editing. It extends the classic vi editor with features like syntax highlighting, visual mode, multiple buffers, and extensive plugin support. Vim operates primarily through keyboard commands in different modes, enabling powerful text manipulation without leaving the home row. While the learning curve is steep, proficiency enables very fast editing. Configuration lives in ~/.vimrc (or ~/.vim/vimrc). Plugins can be managed with package managers like vim-plug, Vundle, or native packages (Vim 8+).

How do I run a basic vim example?

Run `vim [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does + _line_ do in vim?

Start at specified line number