From b76270bf9e6dd375e495fec92140a79a79415d27 Mon Sep 17 00:00:00 2001 From: Patrick J Volkerding Date: Wed, 19 May 2010 08:58:23 +0000 Subject: Slackware 13.1 Wed May 19 08:58:23 UTC 2010 Slackware 13.1 x86_64 stable is released! Lots of thanks are due -- see the RELEASE_NOTES and the rest of the ChangeLog for credits. The ISOs are on their way to replication, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We are taking pre-orders now at store.slackware.com, and offering a discount if you sign up for a subscription. Consider picking up a copy to help support the project. Thanks again to the Slackware community for testing, contributing, and generally holding us to a high level of quality. :-) Enjoy! --- slackbook/html/vi-modes.html | 200 ------------------------------------------- 1 file changed, 200 deletions(-) delete mode 100644 slackbook/html/vi-modes.html (limited to 'slackbook/html/vi-modes.html') diff --git a/slackbook/html/vi-modes.html b/slackbook/html/vi-modes.html deleted file mode 100644 index df8387976..000000000 --- a/slackbook/html/vi-modes.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - -Modes - - - - - - - - - - - -
-

16.2 Modes

- -

vi operates in various modes, which are used to accomplish -various tasks. When you first start vi, 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.

- -
-

16.2.1 -Command Mode

- -

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 Section -16.7.

- -

Probably the most often used command in command mode is changing to insert mode. This -is accomplished by hitting the i key. The cursor changes shapes, -and -- INSERT -- is displayed at -the bottom of the screen (note that this does not happen in all clones of vi). 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 ESCAPE key.

- -

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 “hjkl”. Here is a simple listing of how these -keys are used to move around:

- -
- --- - - - - - - - - - - - - - - - - - - - - -
hmove left one character
jmove down one character
kmove up one character
lmove right one character
-
- -

Simply press a key to move. As you will see later, these keys can be combined with a -number to move much more efficiently.

- -

Many of the commands that you will use in command mode begin with a colon. For -example, quitting is :q, as discussed earlier. The colon simply -indicates that it is a command, while the “q” tells vi 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.

- -

For example, deleting one line from a file is accomplished by hitting dd. This will remove the line that the cursor is on. Issuing the -command 4dd would tell vi to remove the -line that the cursor is on and the three after that. In general, the number tells vi how many times to perform the command.

- -

You can combine a number with the movement keys to move around several characters at a -time. For example, 10k would move up ten lines on the screen.

- -

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 y key (y stands for yank). Copying the current line is done by typing yy, and this can be prefixed with a number to yank more lines. Then, -move to the location for the copy and hit p. The text is pasted on -the line after the current one.

- -

Cutting text is done by typing dd, and p -can be used to paste the cut text back into the file. Reading in text from another file -is a simple procedure. Just type :r, 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 vi clones even contain filename completion similar to the -shell's.

- -

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.

- -

A simple search is accomplished by hitting the / key, followed -by the text that you are searching for. vi 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 vi to stop as well. For example, a -search for “the” will -cause vi to stop on “then”, “therefore”, and so on. This is because all of those -words do match “the”.

- -

After vi has found the first match, you can continue on to -the next match simply by hitting the / key followed by enter. You -can also search backwards through the file by replacing the slash with the ? key. For example, searching backwards through the file for -“the” would be -accomplished by typing ?the.

-
- -
-

16.2.2 Insert -Mode

- -

Inserting and replacing text is accomplished in insert mode. As previously discussed, -you can get into insert mode by hitting i from command mode. Then, -all text that you type is entered into the current buffer. Hitting the ESCAPE key takes you back into command mode.

- -

Replacing text is accomplished in several ways. From command mode, hitting r 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 R allows you -to replace as many characters as you'd like. To get out of this replacement mode, just -hit ESCAPE to go back into command mode.

- -

There is yet another way to toggle between insertion and replacement. Hitting the INSERT key from command mode will take you into insert mode. Once you -are in insert mode, the keyboard's INSERT 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.

-
-
- - - - - -- cgit v1.2.3