📄 c-shell5.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Shell </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-shell.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-shell4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-shell6.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="100817">6.5 Shell Line Editing</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86425"> </a>The WindSh front end provides a history mechanism similar to the UNIX Korn-shell history facility, including a built-in line editor (with keystrokes similar to the UNIX editor <b class="command">vi</b>) that allows you to scroll, search, and edit previously typed commands. Line editing is available regardless of which interpreter you are using (C or Tcl<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup>), and the command history spans both interpreters--you can switch from one to the other and back, and scroll through the history of both modes.</p><dd><p class="Body"><a name="86447"> </a>The <kbd>ESC</kbd> key switches the shell from normal input mode to <i class="term">edit mode</i>. The history and editing commands in <a href="c-shell5.html#98719">Table 6-15</a> are available in edit mode.</p><dd><p class="Body"><a name="86451"> </a>Some line-editing commands switch the line editor to insert mode until an <kbd>ESC</kbd> is typed (as in <b class="command">vi</b>) or until an<kbd> ENTER </kbd>gives the line to one of the shell interpreters. <kbd>ENTER </kbd>always gives the line as input to the current shell interpreter, from either input or edit mode.</p><dd><p class="Body"><a name="86456"> </a>In input mode, the shell history command <b class="routine"><i class="routine">h</i></b><b>( )</b> (described in <a href="c-shell2.html#97789"><i class="title">System Information</i></a>) displays up to 20 of the most recent commands typed to the shell; older commands are lost as new ones are entered. You can change the number of commands kept in history by running <b class="routine"><i class="routine">h</i></b><b>( )</b> with a numeric argument. To locate a line entered previously, press <kbd>ESC</kbd> followed by one of the search commands listed in <a href="c-shell5.html#98719">Table 6-15</a>; you can then edit and execute the line with one of the commands from <a href="c-shell5.html#98719">Table 6-15</a>. <b><p class="table"><h4 class="EntityTitle"><a name="98719"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 6-15: Shell Line-Editing Commands</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="top"><td colspan=3 rowspan=1><div class="CellHeading"><b><a name="98725"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Basic Control</font></b></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98731"> </a><kbd>h</kbd><b class="routine"><i class="routine"> </i></b>[<i class="textVariable">size</i>]</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98733"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98735"> </a>Display shell history if no argument; otherwise set history buffer to <i class="textVariable">size</i>.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98737"> </a><kbd>ESC</kbd> </div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98739"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98741"> </a>Switch to line-editing mode from regular input mode.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98743"> </a><kbd>ENTER </kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98745"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98747"> </a>Give line to shell and leave edit mode.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="99020"> </a><kbd>CTRL+D</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="99022"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="99024"> </a>Complete symbol or path name (edit mode), display synopsis of current symbol (symbol must be complete, followed by a space), or end shell session (if the command line is empty).</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="99014"> </a><kbd>[tab] </kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="99016"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="99018"> </a>Complete symbol or path name (edit mode).</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98749"> </a><kbd>CTRL+H</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98751"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98753"> </a>Delete a character (backspace).</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98755"> </a><kbd>CTRL+U</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98757"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98759"> </a>Delete entire line (edit mode).</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98761"> </a><kbd>CTRL+L</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98763"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98765"> </a>Redraw line (works in edit mode).</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=2 rowspan=1><div class="CellBody"><a name="98779"> </a><kbd>CTRL+S</kbd> and <kbd>CTRL+Q</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98783"> </a>Suspend output, and resume output.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98785"> </a><kbd>CTRL+W</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98787"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98789"> </a>Display HTML reference page for a routine. </div></td><td width="10"> </td></tr><tr valign="top"><td colspan=3 rowspan=1><div class="CellHeading"><b><a name="98791"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Movement and Search Commands</font></b></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98797"> </a><i class="textVariable">n</i><kbd>G</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98799"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98804"> </a>Go to command number <i class="textVariable">n</i>.<sup><b class="FootnoteMarker">1</b></sup></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98806"> </a><kbd>/</kbd><i class="textVariable">s</i><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><kbd>?</kbd><i class="textVariable">s</i></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98808"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98810"> </a>Search for string <i class="textVariable">s</i> backward in history, or forward.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98812"> </a><kbd>n</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98814"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98816"> </a>Repeat last search.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98818"> </a><i class="textVariable">n</i><kbd>k</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><i class="textVariable">n</i><kbd>-</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98820"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98822"> </a>Get <i class="textVariable">n</i>th previous shell command.*</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98824"> </a><i class="textVariable">n</i><kbd>j</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><i class="textVariable">n</i><kbd>+</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98826"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98828"> </a>Get <i class="textVariable">n</i>th next shell command.*</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98830"> </a><i class="textVariable">n</i><kbd>h</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98832"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98834"> </a>Go left <i class="textVariable">n</i> characters (also <kbd>CTRL+H</kbd>).*</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98836"> </a><i class="textVariable">n</i><kbd>l</kbd><b class="routine"><i class="routine"> </i></b>or <kbd>SPACE</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98838"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98840"> </a>Go right <i class="textVariable">n</i> characters.*</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98842"> </a><i class="textVariable">n</i><kbd>w</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><i class="textVariable">n</i><kbd>W</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98844"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98849"> </a>Go <i class="textVariable">n</i> words forward, or <i class="textVariable">n</i> large words. *<sup><b class="FootnoteMarker">2</b></sup></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98851"> </a><i class="textVariable">n</i><kbd>e</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><i class="textVariable">n</i><kbd>E</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98853"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98855"> </a>Go to end of the <i class="textVariable">n</i>th next word, or <i class="textVariable">n</i>th next large word. *</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98857"> </a><i class="textVariable">n</i><kbd>b</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><i class="textVariable">n</i><kbd>B</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98859"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98861"> </a>Go back <i class="textVariable">n</i> words, or <i class="textVariable">n</i> large words.*</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98863"> </a><kbd>$</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98865"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98867"> </a>Go to end of line.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="98869"> </a><kbd>0</kbd><b class="routine"><i class="routine"> </i></b>or<b class="routine"><i class="routine"> </i></b><kbd>^</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="98871"> </a></div></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -