📄 ch08_10.htm
字号:
<html><head><title>Setting Up vi (UNIX in a Nutshell: System V Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Arnold Robbins" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="1-56592-427-4" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="UNIX in a Nutshell: System V Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Book Title" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_09.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch09_01.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">8.10. Setting Up vi</h2><p>This section describes the following:<a name="IXT-8-123163" /></p><ul><li><p>The <tt class="literal">:set</tt> command</p></li><li><p>Options available with <tt class="literal">:set</tt></p></li><li><p>Example <tt class="literal">.exrc</tt> file</p></li></ul><a name="unut-ch-8-sect-10.1" /><div class="sect2"><h3 class="sect2">8.10.1. The :set Command</h3><p><a name="unut-ch-8-ix-set-command-vi" /><a name="unut-ch-8-ix-vi-editor-set-command" />The <tt class="literal">:set</tt> command allows you to specify options that change characteristics of your editing environment. Options may be put in the <tt class="literal">~/.exrc</tt> file or set during a <tt class="literal">vi</tt> session.</p><p>The colon should not be typed if the command is put in <tt class="literal">.exrc</tt>:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">:set </tt><em class="replaceable"><tt>x</em></td><td>Enable option <em class="emphasis">x</tt></em>.</td></tr><tr><td><tt class="literal">:set no</tt><em class="replaceable"><tt>x</em></td><td>Disable option <em class="emphasis">x</tt></em>.</td></tr><tr><td><tt class="literal">:set </tt><em class="replaceable"><tt>x</em><tt class="literal">=</tt><em class="replaceable">val</em></td><td>Give <em class="emphasis">value</em> to option <em class="emphasis">x</tt></em>.</td></tr><tr><td><tt class="literal">:set</tt></td><td>Show changed options.</td></tr><tr><td><tt class="literal">:set all</tt></td><td>Show all options.</td></tr><tr><td><tt class="literal">:set </tt><em class="replaceable"><tt>x</em><tt class="literal">?</tt></td><td>Show value of option <em class="emphasis">x</tt></em>.</td></tr></table><p></div><a name="unut-ch-8-sect-10.2" /><div class="sect2"><h3 class="sect2">8.10.2. Options Used by :set</h3><p><a href="ch08_10.htm#unut-ch-8-tab-1">Table 8-1</a> contains brief descriptions of the important<tt class="literal">set</tt> command options. In the first column, optionsare listed in alphabetical order; if the option can be abbreviated,that abbreviation is shown in parentheses. The second column shows thedefault setting <tt class="literal">vi</tt> uses unless you issue anexplicit <tt class="literal">set</tt> command (either manually or in the<tt class="literal">.exrc</tt> file). The last column describes what theoption does, when enabled.</p><a name="unut-ch-8-tab-1" /><h4 class="objtitle">Table 8-1. :set Options</h4><table border="1" cellpadding="3"><tr><th>Option</th><th>Default</th><th>Description</th></tr><tr><td><tt class="literal">autoindent (ai)</tt></td><td><tt class="literal">noai</tt></td><td><p>In insert mode,indent each line to the same level as the line aboveor below. Use with the <tt class="literal">shiftwidth</tt> option.</p></td></tr><tr><td><tt class="literal">autoprint (ap)</tt></td><td><tt class="literal">ap</tt></td><td><p>Display changes after each editor command.(For global replacement, display last replacement.)</p></td></tr><tr><td><tt class="literal">autowrite (aw)</tt></td><td><tt class="literal">noaw</tt></td><td><p>Automatically write (save) the file if changedbefore opening another file with <tt class="literal">:n</tt> or before giving Unixcommand with <tt class="literal">:!</tt>.</p></td></tr><tr><td><tt class="literal">beautify (bf)</tt></td><td><tt class="literal">nobf</tt></td><td><p>Ignore all control characters duringinput (except tab, newline, or formfeed).</p></td></tr><tr><td><tt class="literal">directory (dir)</tt></td><td><tt class="literal">/tmp</tt></td><td><p>Name directory in which<tt class="literal">ex</tt>/<tt class="literal">vi</tt> stores buffer files.(Directorymust be writable.)</p></td></tr><tr><td><tt class="literal">edcompatible</tt></td><td><p><tt class="literal">noedcompatible</tt></p></td><td><p>Remember the flags used with the most recent substitute command(global, confirming) and use them for the next substitute command.Despite the name, no version of <tt class="literal">ed</tt>actually behaves this way.</p></td></tr><tr><td><tt class="literal">errorbells (eb)</tt></td><td><tt class="literal">errorbells</tt></td><td>Sound bell when an error occurs.</td></tr><tr><td><tt class="literal">exrc (ex)</tt></td><td><tt class="literal">noexrc</tt></td><td><p>Allow the execution of <tt class="literal">.exrc</tt> files thatreside outside the user's home directory.</p></td></tr><tr><td><tt class="literal">hardtabs (ht)</tt></td><td><tt class="literal">8</tt></td><td><p>Define boundaries for terminal hardware tabs.</p></td></tr><tr><td><tt class="literal">ignorecase (ic)</tt></td><td><tt class="literal">noic</tt></td><td><p>Disregard case during a search.</p></td></tr><tr><td><tt class="literal">lisp</tt></td><td><tt class="literal">nolisp</tt></td><td><p>Insert indents in appropriate Lisp format.<tt class="literal">( )</tt>, <tt class="literal">{ }</tt>,<tt class="literal">[[</tt>, and <tt class="literal">]]</tt>are modified to have meaningfor Lisp.</p></td></tr><tr><td><tt class="literal">list</tt></td><td><tt class="literal">nolist</tt></td><td><p>Print tabs as <tt class="literal">^I</tt>; mark ends of lines with <tt class="literal">$</tt>.(Use <tt class="literal">list</tt> to tell if end character is a tab or a space.)</p></td></tr><tr><td><tt class="literal">magic</tt></td><td><tt class="literal">magic</tt></td><td><p>Wildcard characters <tt class="literal">.</tt> (dot),<tt class="literal">*</tt> (asterisk), and <tt class="literal">[]</tt>(brackets) have special meaning in patterns.</p></td></tr><tr><td><tt class="literal">mesg</tt></td><td><tt class="literal">mesg</tt></td><td><p>Permit system messages to display on terminalwhile editing in <tt class="literal">vi</tt>.</p></td></tr><tr><td><tt class="literal">novice</tt></td><td><tt class="literal">nonovice</tt></td><td><p>Require the use oflong <tt class="literal">ex</tt> command names, such as<tt class="literal">copy</tt> or <tt class="literal">read</tt>.</p></td></tr><tr><td><tt class="literal">number (nu)</tt></td><td><tt class="literal">nonu</tt></td><td><p>Display line numbers on left of screen during editing session.</p></td></tr><tr><td><tt class="literal">open</tt></td><td><tt class="literal">open</tt></td><td><p>Allow entry to <em class="emphasis">open</em>or <em class="emphasis">visual</em>mode from <tt class="literal">ex</tt>.Although not in Solaris <tt class="literal">vi</tt>,this option has traditionally been in <tt class="literal">vi</tt>,and may be in your Unix's version of <tt class="literal">vi</tt>.</p></td></tr><tr><td><tt class="literal">optimize (opt)</tt></td><td><tt class="literal">noopt</tt></td><td><p>Abolish carriage returns at the end of lineswhen printing multiple lines; speed output on dumb terminals whenprinting lines with leading whitespace (spaces or tabs).</p></td></tr><tr><td><tt class="literal">paragraphs (para)</tt></td><td><p><tt class="literal">IPLPPPQP LIpplpipbp</tt></p></td><td><p>Define paragraph delimiters for movementby <tt class="literal">{</tt> or <tt class="literal">}</tt>.The pairs of characters in the value are the names of <tt class="literal">troff</tt>macros that begin paragraphs.</p></td></tr><tr><td><tt class="literal">prompt</tt></td><td><tt class="literal">prompt</tt></td><td><p>Display the <tt class="literal">ex</tt> prompt (:)when <tt class="literal">vi</tt>'s <tt class="literal">Q</tt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -