vi命令打开文件

来源:互联网 发布:海水无机氮数据 编辑:程序博客网 时间:2024/05/16 07:51

文摘摘录 学习vim 书籍:

vi is the Unix command that invokes the vi editor for an existing file or for 

a brand new file. The syntax for the vi command is:

$ vi [filename]

The brackets shown on the above command line indicate that the filename is optional.
The brackets should not be typed. The $ is the Unix prompt. If the filename is omitted,
vi will open an unnamed buffer. You can assign the name when you write the buffer
into a file. 


When you want to open a new file in a directory, give a new filename with the vi
command. For example, if you want to open a new file called practice in the current
directory, you would enter:
$ vi practice
Since this is a new file, the buffer is empty and the screen appears as follows:
~
~
~
"practice" [New file]

The tildes (~) down the lefthand column of the screen indicate that there is no text in
the file, not even blank lines. The prompt line (also called the status line) at the bottom
of the screen echoes the name and status of the file.


You can also edit any existing text file in a directory by specifying its filename. Suppose
that there is a Unix file with the pathname /home/john/letter. If you are already in
the /home/john directory, use the relative pathname. For example:
$ vi letter
brings a copy of the file letter to the screen.
If you are in another directory, give the full pathname to begin editing:
$ vi /home/john/letter

0 0