免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: projl
打印 上一主题 下一主题

《Learning the vi editor》 [复制链接]

论坛徽章:
0
261 [报告]
发表于 2008-06-11 16:23 |只看该作者
Print the members of the argument list (files named on the
command line), with the current argument printed within
brackets ([ ]).

change

[address] c[!]

text

.

Replace the specified lines with text. Add a ! to switch the
autoindent setting during input of text.

copy

[address] co destination

Copy the lines included in address to the specified destination
address. The command t (short for "to") is a synonym for
copy.

delete

[address] d [buffer]

Delete the lines included in address. If buffer is specified,
save or append the text to the named buffer. Buffer names
are the lowercase letters a-z. Uppercase names append text
to the buffer.

edit

e [!][+n] [filename]

Begin editing on filename. If no filename is given, start over
with a copy of the current file. Add a ! to edit the new file
even if the current file has not been saved since the last
change. With the +n argument, begin editing on line n. Or n
may be a pattern, of the form /pattern.

file

f [filename]

论坛徽章:
0
262 [报告]
发表于 2008-06-11 16:23 |只看该作者
Change the name of the current file to filename, which is
considered "not edited." If no filename is specified, print the
current status of the file.

global

[address]g[!]/pattern/[commands]

Execute commands on all lines which contain pattern, or if
address is specified, all lines within that range. If commands
are not specified, print all such lines. Add a ! to execute
commands on all lines not containing pattern.

insert

[address]i[!]

text

.

Insert text at line before the specified address, or at present
address if none is specified. Add a ! to switch the autoindent
setting during input of text.

join

[address]j[!][count]

Place the text in the specified range on one line, with
whitespace adjusted to provide two space characters after a
period (.), no space characters after a ), and one space
character otherwise. Add a ! to prevent whitespace
adjustment.

k

[address] k char

Mark the given address with char, a single lowercase letter.
Return later to the line with 'x. k is equivalent to mark.

list

[address] l [count]

论坛徽章:
0
263 [报告]
发表于 2008-06-11 16:24 |只看该作者
Print the specified lines so that tabs display as ^I and the
ends of lines display as $.

map

map char commands

Define a macro named char in visual mode with the specified
sequence of commands. char is usually the sequence #n,
representing a function key on the keyboard, or one or more
characters.

mark

[address] ma char

Mark the specified line with char, a single lowercase letter.
Return later to the line with 'x.

move

[address] m destination

Move the lines specified by address to the destination
address.

next

n[!] [[+n] filelist]

Edit the next file from the command-line argument list. Use
args to list these files. If filelist is provided, replace the
current argument list with filelist and begin editing on the first
file. With the +n argument, begin editing on line n. Or n may
be a pattern, of the form /pattern.

number

[address] nu [count]

Print each line specified by address, preceded by its buffer line
number. Use # as an alternate abbreviation for number.

open

[address] o [/pattern/]

论坛徽章:
0
264 [报告]
发表于 2008-06-11 16:24 |只看该作者
Enter open mode (vi) at the lines specified by address, or at
the lines matching pattern. Exit open mode with Q.

preserve

pre

Save the current editor buffer as though the system was
about to crash.

print

[address] p [count]

Print the lines specified by address. P is another abbreviation.

put

[address] pu [char]

Restore previously deleted or yanked lines, from named buffer
specified by char, to the line specified by address; if char is
not specified, the last deleted or yanked text is restored.

quit

q[!]

Terminate current editing session. Use ! to discard changes
made since the last save. If the editing session includes
additional files in the argument list that have not yet been
accessed, quit by typing q! or by typing q twice.

read

[address] r filename

Copy the text of filename after the line specified by address.
If filename is not specified, the current filename is used.

read

[address] r ! command

Read the output of command into the text after the line
specified by address.

论坛徽章:
0
265 [报告]
发表于 2008-06-11 16:25 |只看该作者
recover

rec [filename]
Recover filename from system save area.


rewind

rew[!]

Rewind argument list and begin editing the first file in the list.
Add a ! to rewind even if the current file has not been saved
since the last change.

set

se parameterparameter2

Set a value to an option with each parameter, or if no
parameter is supplied, print all options that have been
changed from their defaults. For toggle options, each
parameter can be phrased as "option" or "nooption," other
options can be assigned with the syntax, "option=value". The
form set option? displays the value of option.

shell

sh

Create a new shell. Resume editing when the shell is
terminated.

source

so filename

Read and execute ex commands from filename.

substitute

[address] s [/pattern/repl/][options]

Replace each instance of pattern on the specified lines with
repl. If pattern and repl are omitted, repeat last substitution.
An option of g substitutes all instances of pattern on the line.
An option of c prompts for confirmation before each change.
(Spelling out the command name does not work in Solaris 2.6
vi.) See Chapter 6, for full details.

论坛徽章:
0
266 [报告]
发表于 2008-06-11 16:25 |只看该作者
t

[address] t destination

Copy the lines included in address to the specified destination
address. t is equivalent to copy.

tag
[address] ta tag
Switch the focus of editing to tag.

unabbreviate

una word

Remove word from the list of abbreviations.

undo

u

Reverse the changes made by the last editing command.

unmap

unm char

Remove char from the list of macros.

[address] v/ pattern/[commands]

Execute commands on all lines not containing pattern. If
commands are not specified, print all such lines. v is
equivalent to g!.

version

ve

Print the current version number of the editor and the date
the editor was last changed. Each clone prints something
appropriate.

visual

论坛徽章:
0
267 [报告]
发表于 2008-06-11 16:26 |只看该作者
[address] vi [type] [count]

Enter visual mode at the line specified by address. Exit with Q.
type can be one of -, ^, or . (See the z command). count
specifies an initial window size.

visual

vi [+n] [filename]

Begin editing on filename in visual mode.

write

[address] w[!] [[>>]filename]

Write lines specified by address to filename, or full contents of
buffer if address is not specified. If filename is also omitted,
save the contents of the buffer to the current filename. If >>
filename is used, write contents to the end of the specified
filename. Add a ! to force the editor to write over any current
contents of filename.

write

[address] w !command

Write lines specified by address to command.

wq

wq[!]

Write and quit the file in one movement. The file is always
written.

xit

x

Write file if changes have been made to the buffer since last
write, then quit.

yank

[address] y [char] [count]

论坛徽章:
0
268 [报告]
发表于 2008-06-11 16:27 |只看该作者
Place lines specified by address in named buffer indicated by
char, or if no char is specified place in general buffer.

z

[address] z [type] [count]

Print a window of text with line specified by address at the
top. type can be one of:

+

Place specified line at the top of the window (default).

-

Place specified line at the bottom of the window.

.

Place specified line in the center of the window.

^

Print the previous window.

=

Place specified line in the center of the window and leave the
current line at this line.

count specifies the number of lines to be displayed.

!

[address] !command

Execute command in a shell. If address is specified, apply the
lines contained in address as standard input to command, and
replace the lines with the output and error output. (This is
called filtering the text through the command.)

=

[address] =

Print the line number of the line indicated by address. Default
is line number of last line.

论坛徽章:
0
269 [报告]
发表于 2008-06-11 16:27 |只看该作者
<>

[address] < [count]

or

[address] > [count]

Shift lines specified by address in specified direction. Only
leading spaces and tabs are added or removed when shifting
lines. The shiftwidth option controls the number of columns
that are shifted. Repeating the < or > increases the shift
amount. For example, :>>> shifts three times as much as :>.

address

address

Print the lines specified in address.

RETURN
RETURN
Print the next line in the file.

&
[address] & [options] [count]
Repeat the previous substitute command.

~

[address] ~ [count]

Replace the last used regular expression (even if from a
search, and not from an s command) with the replacement
pattern from the most recent s (substitute) command. See
Section 6.3.4 in Chapter 6 for details.

论坛徽章:
0
270 [报告]
发表于 2008-06-11 16:28 |只看该作者
Appendix C. Setting Options

This appendix describes the important set command options for
Solaris 2.6 vi, nvi 1.79, elvis 2.0, vim 5.1, and vile 8.0.

C.1 Solaris 2.6 vi Options
Table C.1 contains brief descriptions of the important set command options. In
the first column, options are listed in alphabetical order; if the option can be
abbreviated, that abbreviation is shown in parentheses. The second column
shows the default setting that vi uses unless you issue an explicit set command
(either manually or in the .exrc file). The last column describes what the option
does, when enabled.

Table C.1. Solaris 2.6 vi Set Options
Option Default Description
autoindent
(ai) noai
In insert mode, indents each line to the same
level as the line above or below. Use with the
shiftwidth option.
autoprint(ap) ap
Displays changes after each editor command.
(For global replacement, displays last
replacement.)
autowrite
(aw) noaw
Automatically writes (saves) the file if changed
before opening another file with :n or before
giving UNIX command with :!.
beautify(bf) nobf Ignores all control characters during input
(except tab, newline, or formfeed).
directory(dir) /tmp
Names directory in which ex/vi stores buffer
files. (Directory must be writable.)
edcompatible noedcompatible
Remember the flags used with the most recent
substitute command (global, confirming), and
use them for the next substitute command.
Despite the name, no actual version of ed
actually behaved this way.
errorbells
(eb) errorbells Sounds bell when an error occurs.
exrc (ex) noexrc Allows the execution of .exrc files that reside
outside the user's home directory.
hardtabs
(ht) 8 Defines boundaries for terminal hardware tabs.
ignorecase(ic) noic Disregards case during a search.
lisp nolisp
Inserts indents in appropriate lisp format. ( ),
{ }, [[, and ]] are modified to have meaning
for lisp.
list nolist
Prints tabs as ^I; marks ends of lines with $.
(Use list to tell if end character is a tab or a
space.)
magic magic Wildcard characters . (dot), * (asterisk), and []
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP