手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网站运营>建站经验>列表

how to use VI editor

来源:互联网 作者:west263.com 时间:2008-04-16
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
mode, and not in command mode. Also, the width of the indentations can be set with shiftwidth, explained below.
exrc
The .exrc file in the current directory is read during startup. This has to be set either in the environment variable EXINIT or in the .exrc file in your home directory.
mesg
Turn off messages if this option is unset using :set nomesg, so that nobody can bother you while using the editor.
number (nu)
Displays lines with line numbers on the left side.
shiftwidth (sw)
This option takes a value, and determines the width of a software tabstop. (The software tabstop is used for the << and >> commands.) For example, you would set a shift width of 4 with this command: :set sw=4.
showmode (smd)
This option is used to show the actual mode of the editor that you are in. If you are in insert mode, the bottom line of the screen will say INPUT MODE.
warn
This option warns you if you have modified the file, but haven't saved it yet.
window (wi)
This option sets up the number of lines on the window that VI uses. For example, to set the VI editor to use only 12 lines of your screen (because your modem is slow) you would use this: :set wi=12.
wrapscan (ws)
This option affects the behavior of the word search. If wrapscan is set, if the word is not found at the bottom of the file, it will try to search for it at the beginning.
wrapmargin (wm)
If this option has a value greater than zero, the editor will automatically "word wrap". That is, if you get to within that many spaces of the left margin, the word will wrap to the next line, without having to type return. For example, to set the wrap margin to two characters, you would type this: :set wm=2.

Abbreviations and Mapping Keys to Other Keys

One EX editor command that is useful in the VI editor is the abbreviate command. This lets you set up abbreviations for specific strings. The command looks like this: :ab string thing to substitute for. For example, if you had to type the name, "Humuhumunukunukuapua`a" but you didn't want to type the whole name, you could use an abbreviation for it. For this example, the command is entered like this:
:ab 9u Humuhumunukunukuapua`a
Now, whenever you type 9u as a separate word, VI will type in the entire word(s) specified. If you typed in 9university, it will not substitute the word.

To remove a previously defined abbreviation, the command is unabbreviate. To remove the previous example, the command would be ":una 9u" To get your listing of abbreviations, simply just type :ab without any definitions.

Another EX editor command that is useful for customization is the mapping command. There are two kinds of mapping commands. One for command mode, and the other for insert mode. These two commands are :map and :map! respectively. The mapping works similarly to the abbreviation, and you give it a key sequence and give it another key sequence to substitute it with. (The substituted key sequences are usually VI commands.)

The EXINIT Environment Variable and the .exrc file

There are two ways to customize the VI editor. If you create a file called .exrc in your home directory, all the commands in there will be read when VI starts up. The other method is to set an environment variable called EXINIT. The options will be set in your shell's setup file. If you use /bin/csh (C-Shell), the command is as follows, and is put in the .cshrc file:

    setenv EXINIT '...'

If you use /bin/sh or /bin/ksh, the command is as follows, and is put into the .profile file:
    export EXINIT

    EXINIT='...'

Don't put in ... as the example says. In this space put the commands that you want to set up. For example, if you want to have auto indent, line numbering, and the wrap margin of three characters, then the setenv command (for C shell) looks like this:

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!