Linux command
vi 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Open a file
vi [file]
Open at specific line
vi +[line_number] [file]
Open in read-only mode
vi -R [file]
Open multiple files
vi [file1] [file2]
Recover a file
vi -r [file]
说明
vi is the classic Unix visual text editor, present on virtually all Unix-like systems. It uses modal editing where keys have different functions depending on the current mode. On most modern Linux systems, vi is actually a link to vim (Vi IMproved) running in compatibility mode, or a minimal vi clone like nvi. True original vi is rare outside of commercial Unix systems. The modal design allows powerful text manipulation without modifier keys, using the home row for navigation. While the learning curve is steep, proficiency enables very efficient editing. Configuration is stored in ~/.exrc for traditional vi or ~/.vimrc for vim.
参数
- -R
- Read-only mode
- -r _file_
- Recovery mode; list recoverable files or recover specific file
- + _command_
- Execute command after loading
- + _line_
- Start at specified line number
- -c _command_
- Execute command after loading (same as +)
FAQ
What is the vi command used for?
vi is the classic Unix visual text editor, present on virtually all Unix-like systems. It uses modal editing where keys have different functions depending on the current mode. On most modern Linux systems, vi is actually a link to vim (Vi IMproved) running in compatibility mode, or a minimal vi clone like nvi. True original vi is rare outside of commercial Unix systems. The modal design allows powerful text manipulation without modifier keys, using the home row for navigation. While the learning curve is steep, proficiency enables very efficient editing. Configuration is stored in ~/.exrc for traditional vi or ~/.vimrc for vim.
How do I run a basic vi example?
Run `vi [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -R do in vi?
Read-only mode