- 浏览: 99522 次
-
文章分类
最新评论
man vi 2
-cSubcommand
Carries out the ex editor subcommand before viewing with vi begins. The cursor moves to the line affected
by the last subcommand to be carried out. When a null operand is entered, as in -c' ', the vi editor places
the cursor on the first line of the file. The -c flag is incompatible with the + flag. Do not specify both
flags at the same time.
-l
Enters the vi editor in LISP mode. In this mode, the vi editor creates indents appropriate for LISP code,
and the (, ), {, }, [[, and ]] subcommands are modified to act appropriately for LISP.
-r[File]
Recovers a file after a vi editor or system malfunction. If you do not specify the File variable, the vi
editor displays a list of all saved files.
-R
Sets the readonly option to protect the file against overwriting.
-tTag
Edits the file containing the Tag variable and positions the vi editor at its definition. To use this flag,
you must first create a database of function names and their locations using the ctags command.
-v
Enters the vi editor in the verbose mode.
-wNumber
Sets the default window size to the value specified by the Number variable. This flag is useful when you
use the vi editor over a low-speed line.
-yNumber
Overrides the maximum line setting of 1,048,560 with any value greater than 1024. You should request twice
the number of lines that you require because the vi editor uses the extra lines for buffer manipulation.
+[Subcommand]
Carries out the ex editor subcommand before editing begins. If you do not specify the Subcommand variable,
the cursor is placed on the first line of the file. This + flag is incompatible with the -c flag. Do not
specify both flags at the same time.
vi General Subcommand Syntax
Use the following general syntax to enter subcommands:
[Named_Buffer] [Operator] [Number] Object Tip: Square brackets indicate optional items.
[Named_Buffer]
Specifies a temporary text storage area.
[Operator]
Specifies the subcommand or action; instructs the vi editor.
[Number]
Specifies either the extent of the action or a line address as a whole number.
Object
Specifies what to act on, such as a text object (a character, word, sentence, paragraph, section, character
string) or a text position (a line, position in the current line, screen position).
Counts before Subcommands
You can put a number in front of many subcommands. The vi editor interprets this number in one of the following
ways:
* Go to the line specified by the Number parameter:
5G
10Z
* Go to the column specified by the Number parameter:
25|
* Scroll the number of lines up or down specified by the Number parameter:
10Ctrl-U
10Ctrl-D
vi Editor Subcommands
Use the subcommands to perform these kinds of actions:
* Moving the cursor
* Editing text
* Manipulating files
* Other actions
Moving the Cursor
Use subcommands to move the cursor within a file in these ways:
* Moving within a line
* Moving within a line by character position
* Moving to words
* Moving by line position
* Moving to sentences, paragraphs, or sections
* Moving by redrawing the screen
* Paging and scrolling
* Searching for patterns
* Marking a specific location in a file and returning
Moving within a Line
Enter the following subcommands in command mode. You can cancel an incomplete command by pressing the Esc key.
If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
Left Arrow or h or Ctrl-H
Moves the cursor one character to the left.
Down Arrow or j or Ctrl-J or Ctrl-N
Moves the cursor down one line (it remains in the same column).
Up Arrow or k or Ctrl-P
Moves the cursor up one line (it remains in the same column).
Right Arrow or l
Moves the cursor one character to the right.
Moving within a Line by Character Position
Enter the following subcommands in command mode. You can cancel an incomplete command by pressing the Esc key.
If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
^
Moves the cursor to the first nonblank character.
0
Moves the cursor to the beginning of the line.
$
Moves the cursor to the end of the line.
fx
Moves the cursor to the next x character.
Fx
Moves the cursor to the last x character.
tx
Moves the cursor to one column before the next x character.
Tx
Moves the cursor to one column after the last x character.
;
Repeats the last f, F, t, or T subcommand.
,
Repeats the last f, F, t, or T subcommand in the opposite direction.
Number|
Moves the cursor to the specified column.
Moving to Words
Enter the following subcommands in command mode. If you need information about the format of vi subcommands, "vi
General Subcommand Syntax."
w
Moves the cursor to the next small word.
b
Moves the cursor to the previous small word.
e
Moves the cursor to the next end of a small word.
W
Moves the cursor to the next big word.
B
Moves the cursor to the previous big word.
E
Moves the cursor to the next end of a big word.
Moving by Line Position
Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."
H
Moves the cursor to the top line on the screen.
L
Moves the cursor to the last line on the screen.
M
Moves the cursor to the middle line on the screen.
+
Moves the cursor to the next line at its first nonblank character.
-
Moves the cursor to the previous line at its first nonblank character.
Enter
Moves the cursor to the next line at its first nonblank character.
Moving to Sentences, Paragraphs, or Sections
Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
(
Places the cursor at the beginning of the previous sentence, or the previous s-expression if you are in
LISP mode.
)
Places the cursor at the beginning of the next sentence, or the next s-expression if you are in LISP mode.
{
Places the cursor at the beginning of the previous paragraph, or at the next list if you are in LISP mode.
}
Places the cursor at the beginning of the next paragraph, at the next section if you are in C mode, or at
the next list if you are in LISP mode.
]]
Places the cursor at the next section, or function if you are in LISP mode.
[[
Places the cursor at the previous section, or function if you are in LISP mode.
Moving by Redrawing the Screen
Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
z
Redraws the screen with the current line at the top of the screen.
z-
Redraws the screen with the current line at the bottom of the screen.
z.
Redraws the screen with the current line at the center of the screen.
/Pattern/z-
Redraws the screen with the line containing the character string, specified by the Pattern parameter, at
the bottom.
Paging and Scrolling
Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
Ctrl-U
Scrolls up one-half screen.
Ctrl-D
Scrolls down one-half screen.
Ctrl-F
Scrolls forward one screen.
Ctrl-B
Scrolls backward one screen.
Ctrl-E
Scrolls the window down one line.
Ctrl-Y
Scrolls the window up one line.
z+
Pages up.
z^
Pages down.
Searching for Patterns
Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
[Number]G
Places the cursor at the line number specified by the Number parameter or at the last line if the Number
parameter is not specified.
/Pattern
Places the cursor at the next line containing the character string specified by the Pattern parameter.
?Pattern
Places the cursor at the next previous line containing the character string specified by the Pattern
parameter.
n
Repeats the last search for the text specified by the Pattern parameter in the same direction.
N
Repeats the last search for the text specified by the Pattern parameter in the opposite direction.
/Pattern/+Number
Places the cursor the specified number of lines after the line matching the character string specified by
the Pattern parameter.
?Pattern?-Number
Places the cursor the specified number of lines before the line matching the character string specified by
the Pattern parameter.
%
Finds the parenthesis or brace that matches the one at current cursor position.
Editing Text
The subcommands for editing enable you to perform the following tasks:
* Marking a specific location in a file and returning
* Adding text to a file
* Changing text while in input mode
* Changing text from command mode
* Copying and moving text
* Restoring and repeating changes
Marking a Specific Location in a File and Returning
Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
"
Moves the cursor to the previous location of the current line.
"
Moves the cursor to the beginning of the line containing the previous location of the current line.
mx
Marks the current position with the letter specified by the x parameter.
`x
Moves the cursor to the mark specified by the x parameter.
'x
Moves the cursor to the beginning of the line containing the mark specified by the x parameter.
Adding Text to a File (Text Input Mode)
Enter the following subcommands in command mode to change the vi editor into text input mode. If you need
information about the format of vi subcommands, see "vi General Subcommand Syntax."
aText
Inserts text specified by the Text parameter after the cursor. End text input mode by pressing the Esc key.
AText
Adds text specified by the Text parameter to the end of the line. End text input mode by pressing the Esc
key.
iText
Inserts text specified by the Text parameter before the cursor. End text input mode by pressing the Esc
key.
IText
Inserts text specified by the Text parameter before the first nonblank character in the line. End text
input mode by pressing the Esc key.
o
Adds an empty line below the current line. End text input mode by pressing the Esc key.
O
Adds an empty line above the current line. End text input mode by pressing the Esc key.
Changing Text While in Input Mode
Use the following subcommands only while in text input mode. These commands have different meanings in command
mode. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
Ctrl-D
Goes back to previous autoindent stop.
^ Ctrl-D
Ends autoindent for this line only.
0Ctrl-D
Moves cursor back to left margin.
Esc
Ends insertion and returns to command state.
Ctrl-H
Erases the last character.
Ctrl-Q
Enters any character if xon is disabled.
Ctrl-V
Enters any character.
Ctrl-W
Erases the last small word.
\
Quotes the erase and kill characters.
Ctrl-?
Interrupts and ends insert or the Ctrl-D key sequence.
Changing Text from Command Mode
Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key.
If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
C
Changes the rest of the line (same as c$).
cc
Changes a line.
cw
Changes a word.
cwText
Changes a word to the text specified by the Text parameter.
D
Deletes the rest of the line (same as d$).
dd
Deletes a line.
dw
Deletes a word.
J
Joins lines.
rx
Replaces the current character with the character specified by x.
RText
Overwrites characters with the text specified by the Text parameter.
s
Substitutes characters (same as cl).
S
Substitutes lines (same as cc).
u
Undoes the previous change.
x
Deletes a character at the cursor.
X
Deletes a character before the cursor (same as dh).
<<
Shifts one line to the left.
<L
Shifts all lines from the cursor to the end of the screen to the left.
>>
Shifts one line to the right.
>L
Shifts all lines from the cursor to the end of the screen to the right.
~
Changes letter at the cursor to the opposite case.
!
Indents for LISP.
Copying and Moving Text
Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key.
If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
p
Puts back text from the undo buffer after the cursor.
P
Puts back text from the undo buffer before the cursor.
"xp
Puts back text from the x buffer.
"xd
Deletes text into the x buffer.
y
Places the object that follows (for example, w for word) into the undo buffer.
"xy
Places the object that follows into the x buffer, where x is any letter.
Y
Places the line in the undo buffer.
Restoring and Repeating Changes
Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key.
If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
u
Undoes the last change.
Tip: After an undo, the cursor moves to the first non-blank character on the updated current line.
U
Restores the current line if the cursor has not left the line since the last change.
.
Repeats the last change or increments the "np command.
Notes:
1 This subcommand will repeat the last change, including an undo. Therefore, after an undo, repeat
performs an undo rather than repeat the last change.
2 This subcommand is not meant for use with a macro. Enter @@ (two at signs) to repeat a macro.
"n p
Retrieves the nth last delete of a complete line or block of lines.
Manipulating Files
The subcommands for manipulating files allow you to do the tasks outlined in the following sections:
* Saving changes to a file
* Editing a second file
* Editing a list of files
* Finding file information
Saving Changes to a File
Use the following subcommands in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."
:w
Writes the edit buffer contents to the original file. If you are using this subcommand within the ex
editor, you do not need to type the : (colon).
:w File
Writes the edit buffer contents to the file specified by the File parameter. If you are using this
subcommand within the ex editor, you do not need to type the : (colon).
:w! File
Overwrites the file specified by the File parameter with the edit buffer contents. If you are using this
subcommand within the ex editor, you do not need to type the : (colon).
Editing a Second File
Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."
:e File
Edits the specified file. If you are using this subcommand from the ex editor, you do not need to type the
: (colon).
:e!
Re-edits the current file and discards all changes.
:e + File
Edits the specified file starting at the end.
:e + Number File
Edits the specified file starting at the specified line number.
:e #
Edits the alternate file. The alternate file is usually the previous file name before accessing another
file with a :e command. However, if changes are pending on the current file when a new file is called, the
new file becomes the alternate file. This subcommand is the same as the Ctrl-A subcommand.
:r File
Reads the file into the editing buffer by adding new lines below the current line. If you are using this
subcommand from the ex editor, you do not need to type the : (colon).
:r !Command
Runs the specified command and places its output into the file by adding new lines below the current cursor
position.
:ta Tag
Edits a file containing the Tag tag starting at the location of the tag. To use this subcommand, you must
first create a database of function names and their locations using the ctags command. If you are using
this subcommand from the ex editor, you do not need to type the : (colon).
Ctrl-]
Edits a file containing the tag associated with the current word starting at the location of the tag. To
use this subcommand, you must first create a database of function names and their locations using the ctags
command. Ctrl-T edits a file at the editing position where the previous Ctrl-] subcommand was issued. If
multiple Ctrl-] subcommands have been issued, then multiple Ctrl-T subcommands can be used to return to
previous editing positions where Ctrl-] subcommands were issued.
Ctrl-A
Edits the alternate file. The alternate file is usually the previous current file name. However, if changes
are pending on the current file when a new file is called, the new file becomes the alternate file. This
subcommand is the same as the :e # subcommand.
Editing a List of Files
Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."
:n
Edits the next file in the list entered on the command line. If you are using this subcommand from the ex
editor, a : (colon) is not needed.
:n Files
Specifies a new list of files to edit. If you are using this subcommand from the ex editor, a : (colon) is
not needed.
Finding File Information
Enter the following subcommand in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax".
Ctrl-G
Shows the current file name, current line number, number of lines in the file, and percentage of the way
through the file where the cursor is located.
Other Actions
The vi editor provides the subcommands described in the following sections:
* Adjusting the screen
* Entering shell commands
* Interrupting and ending the vi editor
Adjusting the Screen
Enter the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc
key. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
Ctrl-L
Clears and redraws the screen.
Ctrl-R
Redraws the screen and eliminates blank lines marked with @ (at sign).
zNumber
Makes the window the specified number of lines long.
Entering Shell Commands
The following subcommands allow you to run a command within the vi editor. Enter these subcommands in command
mode. If you need information about the format of vi subcommands, see "vi General Subcommand Syntax."
:sh
Enters the shell to allow you to run more than one command. You can return to the vi editor by pressing the
Ctrl-D key sequence. If you are using this subcommand within the ex editor, a : (colon) is not needed.
:!Command
Runs the specified command and then returns to the vi editor. If you are using this subcommand within the
ex editor, a : (colon) is not needed.
Tip: The # (alternate file), % (current file), and ! (previous command) special characters are expanded
when following a :! subcommand. To prevent any of these characters from being expanded, use the \
(backslash).
:!!
Repeats the last :!Command subcommand.
Number!!Command
Runs the specified command and replaces the lines specified by Number with the output of the command. If a
number is not specified, the default value is 1. If the command expects standard input, the specified lines
are used as input.
!Object Command
Runs the specified command and replaces the object specified by the Object parameter with the output of the
command. If the command expects standard input, the specified object is used as input.
Interrupting and Ending the vi Editor
Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."
Q
Enters the ex editor in command mode.
ZZ
Exits the vi editor, saving changes.
:q
Quits the vi editor. If you have changed the contents of the editing buffer, the vi editor displays a
warning message and does not quit. If you are using this subcommand from the ex editor, a : (colon) is not
needed.
:q!
Quits the vi editor, discarding the editing buffer. If you are using this subcommand from the ex editor, a
: (colon) is not needed.
Esc
Ends text input or ends an incomplete subcommand.
Ctrl-?
Interrupts a subcommand.
Exit Status
The following exit values are returned:
0
Indicates successful completion.
>0
Indicates an error occurred.
Input Files
Input files must be text files or files that are similar to text files except for an incomplete last line that
contains no null characters.
The .exrc files must be text files consisting of ex commands.
The $HOME/.vi_history file is an auto-generated text file that records the last line mode command history.
By default, the vi editor reads lines from the files to be edited without interpreting any of those lines as any
form of vi editor command.
Related Information
The ctags command, ed command, ex command, sed command, tvi command, view command.
The .profile file.
相关推荐
Oracle数据库管理是IT行业中至关重要的技能之一,而与之紧密相关的文本编辑器——man、vi、vim和emacs,则是每一个数据库管理员和系统管理员必备的工具。这些编辑器在Linux和Unix环境中尤其常见,它们提供了高效、...
2.解压缩 tar zxvf manpages-zh-1.5.1.tar.gz 3.安装(需取得管理员权限) ./configure --prefix=/usr/local/zhman --disable-zhtw make make install 4.编辑配置文件 vi /usr/bin/zhman #!/bin/bash #name=zhman ...
(2)Vi的使用 Vi编辑器基本上分为三种模式,分别是“一般模式”、“编辑模式”和“命令模式”。 * 一般模式:以Vi打开一个文档就直接进入一般模式(这是默认的模式)。在这个模式中,可以使用“上下左右”键来...
这里,我们假设`manpages-zh-1.5`目录下有多个子目录(如`man1`、`man2`等),这些对应于不同的`man`页类别。`cp`命令将所有汉化页面复制到新建的目录中。 然而,仅完成上述步骤还不足以让系统默认显示中文`man`...
对于初学者,学习vi的命令手册(`man vi`)是非常有用的,手册中包含了详细的命令解释和示例。 在文件内容中,提到了一些与vi无关但非常基础的Linux命令,这些命令在日常的系统管理中同样重要: - `man`:查看命令...
通过阅读`man vi`获取官方手册,或者参考网上的教程,如《VI编辑器教程》等,可以帮助你更好地掌握VI的高级特性。 VI编辑器虽然初学者可能觉得不易上手,但其强大的功能和高效的操作方式使其成为许多系统管理员和...
12. **另存为新文件**:在不退出`vi`的情况下,将文件另存为`man.test.config`,需要在命令模式下输入`:w man.test.config`。 13. **删除字符**:移动到第25行并删除15个字符,先输入`25G`定位到25行,然后在正常...
这相当于运行`man`命令,但更为便捷。 3. **自动定位编译错误** 类似于VC,VI也能自动定位编译错误。在VI内部运行`make`命令后,按下回车即可跳转到首个错误位置。记得使用内置的`:make`命令,而不是外部的`!make`...
- 查看`time`命令相关的系统调用帮助文档:`$ man 2 time` **2.3 关键字搜索** 除了通过具体的命令名称查询外,还可以使用`-k`选项或`apropos`命令来查找包含特定关键字的手册页。 - **命令格式:** - `$ man -...
- 学习VI,可以参考官方手册页`man vi`或`man vim`。 - "VI Pocket Reference"、"Learning the VI Editor"等书籍是深入理解VI的好资料。 - 在线教程如"Vim Adventures"提供互动式学习体验。 通过熟练掌握VI编辑...
- `/\<man\>`:查找man,而不是Batman或manic等其他字符串。 - `?word`:向光标之前寻找一个字符串名称为word的字符串。 - `n`:重复上次的搜索。 - `N`:按相反方向重复上次的搜索。 - `:1,$s/word1/word2/g`:从第...
深入理解vi,还需要阅读官方手册页(`man vi`),参加在线教程,或者查阅相关书籍。不断实践是掌握vi的关键,逐步熟悉其命令集,你会发现它在文本编辑方面的强大功能。 总结,vi编辑器是Linux世界里不可或缺的工具...
**vi编辑器基础** vi(Visual Editor)是Linux和Unix系统中最常用的文本编辑器之一,它的全名是“视觉编辑器...要深入学习vi,建议阅读官方手册页(`man vi`)或相关教程。通过实践,你会逐渐熟悉这个强大的文本编辑器。
学习Vi编辑器,可以通过官方手册页(`man vi`或`man vim`),在线教程,以及各种指南来提升技能。熟练掌握Vi可以显著提高Linux系统的管理效率。 总的来说,虽然Vi编辑器的学习曲线较陡,但其高效的操作方式和广泛的...
2. **常用操作**: - `pwd`:显示当前工作目录。 - `passwd`:更改用户密码。 - `csh`, `bash`:切换不同的Shell环境。 - `telnet`:远程登录到其他服务器。 3. **vi编辑器的基本操作**: - `vi filename`:...
1. 通过命令man vi查看手册页。如果显示的是vim的说明书页,则说明系统上安装的是vim。 2. 通过输入vi或vim启动编辑器。如果屏幕显示的是空白或者帮助信息,那么系统上可能是vim。如果只显示vi编辑器的界面,则很...
- `man & info`: 查阅命令的手册页或信息文档。 - `LANG=en`: 设置语言环境为英文。 - `sync`: 同步文件系统缓冲区到磁盘。 - `date`: 显示或设置系统日期和时间。 - `cal`: 显示日历,如`cal 2006`显示2006年...
* 练习一:在 /root 目录下建立一个名为 vitest 的目录,并在其中创建一个名为 man.config 的文件,然后使用 VI 文本编辑器来编辑该文件。 * 练习二:在 /tmp 目录下创建两个文件 t1 和 t2,然后使用 VI 文本编辑器...
使用man命令获取date帮助信息并将其重定向到file10,再用Vi编辑file10,执行删除、复原、修改等操作;编写一个名为"exam2"的Shell脚本,实现创建目录、切换目录和显示时间等功能;利用Vi编写一个包含date、cal、pwd...
一些常用的参考手册包括`man vi`和`man vim`,以及在线资源如`vim.org`。 了解并熟练掌握这些基本操作,将使你在Linux环境中更加得心应手。不断练习和探索,你会发现VI编辑器的强大和效率远超一般文本编辑器。