diff options
Diffstat (limited to 'misc/slackbook/html/vi-modes.html')
-rw-r--r-- | misc/slackbook/html/vi-modes.html | 200 |
1 files changed, 0 insertions, 200 deletions
diff --git a/misc/slackbook/html/vi-modes.html b/misc/slackbook/html/vi-modes.html deleted file mode 100644 index df838797..00000000 --- a/misc/slackbook/html/vi-modes.html +++ /dev/null @@ -1,200 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta name="generator" content="HTML Tidy, see www.w3.org" /> -<title>Modes</title> -<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /> -<link rel="HOME" title="Slackware Linux Essentials" href="index.html" /> -<link rel="UP" title="Vi" href="vi.html" /> -<link rel="PREVIOUS" title="Vi" href="vi.html" /> -<link rel="NEXT" title="Opening Files" href="vi-opening-files.html" /> -<link rel="STYLESHEET" type="text/css" href="docbook.css" /> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> -</head> -<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084" -alink="#0000FF"> -<div class="NAVHEADER"> -<table summary="Header navigation table" width="100%" border="0" cellpadding="0" -cellspacing="0"> -<tr> -<th colspan="3" align="center">Slackware Linux Essentials</th> -</tr> - -<tr> -<td width="10%" align="left" valign="bottom"><a href="vi.html" -accesskey="P">Prev</a></td> -<td width="80%" align="center" valign="bottom">Chapter 16 Vi</td> -<td width="10%" align="right" valign="bottom"><a href="vi-opening-files.html" -accesskey="N">Next</a></td> -</tr> -</table> - -<hr align="LEFT" width="100%" /> -</div> - -<div class="SECT1"> -<h1 class="SECT1"><a id="VI-MODES" name="VI-MODES">16.2 Modes</a></h1> - -<p><tt class="COMMAND">vi</tt> operates in various modes, which are used to accomplish -various tasks. When you first start <tt class="COMMAND">vi</tt>, you are placed into -command mode. From this point, you can issue various commands to manipulate text, move -around in the file, save, quit, and change modes. Editing the text is done in insert -mode. You can quickly move between modes with a variety of keystrokes, which are -explained below.</p> - -<div class="SECT2"> -<h2 class="SECT2"><a id="VI-MODES-COMMAND-MODE" name="VI-MODES-COMMAND-MODE">16.2.1 -Command Mode</a></h2> - -<p>You are first placed into command mode. From this mode, you cannot directly enter text -or edit what is already there. However, you can manipulate the text, search, quit, save, -load new files, and more. This is intended only to be an introduction to the command -mode. For a description of the various commands, see <a href="vi-keys.html">Section -16.7</a>.</p> - -<p>Probably the most often used command in command mode is changing to insert mode. This -is accomplished by hitting the <b class="KEYCAP">i</b> key. The cursor changes shapes, -and <span class="emphasis"><i class="EMPHASIS">-- INSERT --</i></span> is displayed at -the bottom of the screen (note that this does not happen in all clones of <tt -class="COMMAND">vi</tt>). From there, all your keystrokes are entered into the current -buffer and are displayed to the screen. To get back into command mode, hit the <b -class="KEYCAP">ESCAPE</b> key.</p> - -<p>Command mode is also where you move around in the file. On some systems, you can use -the arrow keys to move around. On other systems, you may need to use the more traditional -keys of “<b class="KEYCAP">hjkl</b>”. Here is a simple listing of how these -keys are used to move around:</p> - -<div class="INFORMALTABLE"><a id="AEN5604" name="AEN5604"></a> -<table border="0" frame="void" width="100%" class="CALSTABLE"> -<col width="25%" /> -<col width="75%" /> -<tbody> -<tr> -<td><b class="KEYCAP">h</b></td> -<td>move left one character</td> -</tr> - -<tr> -<td><b class="KEYCAP">j</b></td> -<td>move down one character</td> -</tr> - -<tr> -<td><b class="KEYCAP">k</b></td> -<td>move up one character</td> -</tr> - -<tr> -<td><b class="KEYCAP">l</b></td> -<td>move right one character</td> -</tr> -</tbody> -</table> -</div> - -<p>Simply press a key to move. As you will see later, these keys can be combined with a -number to move much more efficiently.</p> - -<p>Many of the commands that you will use in command mode begin with a colon. For -example, quitting is <b class="KEYCAP">:q</b>, as discussed earlier. The colon simply -indicates that it is a command, while the “<b class="KEYCAP">q</b>” tells <tt -class="COMMAND">vi</tt> to quit. Other commands are an optional number, followed by a -letter. These commands do not have a colon before them, and are generally used to -manipulate the text.</p> - -<p>For example, deleting one line from a file is accomplished by hitting <b -class="KEYCAP">dd</b>. This will remove the line that the cursor is on. Issuing the -command <b class="KEYCAP">4dd</b> would tell <tt class="COMMAND">vi</tt> to remove the -line that the cursor is on and the three after that. In general, the number tells <tt -class="COMMAND">vi</tt> how many times to perform the command.</p> - -<p>You can combine a number with the movement keys to move around several characters at a -time. For example, <b class="KEYCAP">10k</b> would move up ten lines on the screen.</p> - -<p>Command mode can also be used to cut and paste, insert text, and read other files into -the current buffer. Copying text is accomplished with the <b class="KEYCAP">y</b> key (<b -class="KEYCAP">y</b> stands for yank). Copying the current line is done by typing <b -class="KEYCAP">yy</b>, and this can be prefixed with a number to yank more lines. Then, -move to the location for the copy and hit <b class="KEYCAP">p</b>. The text is pasted on -the line after the current one.</p> - -<p>Cutting text is done by typing <b class="KEYCAP">dd</b>, and <b class="KEYCAP">p</b> -can be used to paste the cut text back into the file. Reading in text from another file -is a simple procedure. Just type <b class="KEYCAP">:r</b>, followed by a space and the -file name that contains the text to be inserted. The file's contents will be pasted into -the current buffer on the line after the cursor. More sophisticated <tt -class="COMMAND">vi</tt> clones even contain filename completion similar to the -shell's.</p> - -<p>The final use that will be covered is searching. Command mode allows for simple -searching, as well as complicated search-and-replace commands that make use of a powerful -version of regular expressions. A complete discussion of regular expressions is beyond -the scope of this chapter, so this section will only cover simple means of searching.</p> - -<p>A simple search is accomplished by hitting the <b class="KEYCAP">/</b> key, followed -by the text that you are searching for. <tt class="COMMAND">vi</tt> will search forward -from the cursor to the end of the file for a match, stopping when it finds one. Note that -inexact matches will cause <tt class="COMMAND">vi</tt> to stop as well. For example, a -search for “<span class="emphasis"><i class="EMPHASIS">the</i></span>” will -cause <tt class="COMMAND">vi</tt> to stop on “<span class="emphasis"><i -class="EMPHASIS">then</i></span>”, “<span class="emphasis"><i -class="EMPHASIS">therefore</i></span>”, and so on. This is because all of those -words do match “<span class="emphasis"><i -class="EMPHASIS">the</i></span>”.</p> - -<p>After <tt class="COMMAND">vi</tt> has found the first match, you can continue on to -the next match simply by hitting the <b class="KEYCAP">/</b> key followed by enter. You -can also search backwards through the file by replacing the slash with the <b -class="KEYCAP">?</b> key. For example, searching backwards through the file for -“<span class="emphasis"><i class="EMPHASIS">the</i></span>” would be -accomplished by typing <b class="KEYCAP">?the</b>.</p> -</div> - -<div class="SECT2"> -<h2 class="SECT2"><a id="VI-MODES-INSET-MODE" name="VI-MODES-INSET-MODE">16.2.2 Insert -Mode</a></h2> - -<p>Inserting and replacing text is accomplished in insert mode. As previously discussed, -you can get into insert mode by hitting <b class="KEYCAP">i</b> from command mode. Then, -all text that you type is entered into the current buffer. Hitting the <b -class="KEYCAP">ESCAPE</b> key takes you back into command mode.</p> - -<p>Replacing text is accomplished in several ways. From command mode, hitting <b -class="KEYCAP">r</b> will allow you to replace the one character underneath the cursor. -Just type the new character and it will replace the one under the cursor. You will then -be immediately placed back into command mode. Hitting <b class="KEYCAP">R</b> allows you -to replace as many characters as you'd like. To get out of this replacement mode, just -hit <b class="KEYCAP">ESCAPE</b> to go back into command mode.</p> - -<p>There is yet another way to toggle between insertion and replacement. Hitting the <b -class="KEYCAP">INSERT</b> key from command mode will take you into insert mode. Once you -are in insert mode, the keyboard's <b class="KEYCAP">INSERT</b> key serves as a toggle -between insert and replace. Hitting it once will allow you to replace. Hitting it once -more will once again allow you to insert text.</p> -</div> -</div> - -<div class="NAVFOOTER"> -<hr align="LEFT" width="100%" /> -<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" -cellspacing="0"> -<tr> -<td width="33%" align="left" valign="top"><a href="vi.html" accesskey="P">Prev</a></td> -<td width="34%" align="center" valign="top"><a href="index.html" -accesskey="H">Home</a></td> -<td width="33%" align="right" valign="top"><a href="vi-opening-files.html" -accesskey="N">Next</a></td> -</tr> - -<tr> -<td width="33%" align="left" valign="top">Vi</td> -<td width="34%" align="center" valign="top"><a href="vi.html" accesskey="U">Up</a></td> -<td width="33%" align="right" valign="top">Opening Files</td> -</tr> -</table> -</div> -</body> -</html> - |