From 5a12e7c134274dba706667107d10d231517d3e05 Mon Sep 17 00:00:00 2001 From: Patrick J Volkerding Date: Wed, 26 Aug 2009 10:00:38 -0500 Subject: Slackware 13.0 Wed Aug 26 10:00:38 CDT 2009 Slackware 13.0 x86_64 is released as stable! Thanks to everyone who helped make this release possible -- see the RELEASE_NOTES for the credits. The ISOs are off to the replicator. This time it will be a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We're taking pre-orders now at store.slackware.com. Please consider picking up a copy to help support the project. Once again, thanks to the entire Slackware community for all the help testing and fixing things and offering suggestions during this development cycle. As always, have fun and enjoy! -P. --- slackbook/html/vi.html | 199 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 slackbook/html/vi.html (limited to 'slackbook/html/vi.html') diff --git a/slackbook/html/vi.html b/slackbook/html/vi.html new file mode 100644 index 000000000..d5fbf29f9 --- /dev/null +++ b/slackbook/html/vi.html @@ -0,0 +1,199 @@ + + + + +Vi + + + + + + + + + + +
+

Chapter 16 Vi

+ +
+
+
Table of Contents
+ +
16.1 Starting vi
+ +
16.2 Modes
+ +
16.3 Opening Files
+ +
16.4 Saving Files
+ +
16.5 Quitting vi
+ +
16.6 vi Configuration
+ +
16.7 Vi Keys
+
+
+ +

vi(1) is the standard Unix text editing program, and while +mastering it is not as essential as it once was, is still a very rewarding goal. There +are several versions (or clones) of vi available, including vi, elvis, vile, +and vim. One of these is available on just about any version of +Unix, as well as on Linux. All of these versions include the same basic feature set and +commands, so learning one clone should make it easy to learn another. With the variety of +text editors included with Linux distributions and Unix variants these days, many people +no longer use vi. Still, it remains the most universal text +editor across Unix and Unix work-alikes. Mastering vi means you +should never be sitting at a Unix machine and not be comfortable with at least one +powerful text editor.

+ +

vi includes a number of powerful features including syntax +highlighting, code formatting, a powerful search-and-replace mechanism, macros, and more. +These features make it especially attractive to programmers, web developers, and the +like. System administrators will appreciate the automation and integration with the shell +that is possible.

+ +

On Slackware Linux, the default version of vi available is +elvis. Other versions - including vim +and gvim - are available if you've installed the proper +packages. gvim is an X Window version of vim that includes toolbars, detachable menus, and dialog boxes.

+ +
+

16.1 Starting vi

+ +

vi can be started from the command line in a variety of ways. +The simplest form is just:

+ + + + + +
+
+% vi
+
+
+ +
+

Figure 16-1. A vi session.

+ +

+
+ +

This will start up vi with an empty buffer. At this point, +you'll see a mostly blank screen. It is now in “command mode”, waiting for +you to do something. For a discussion of the various vi modes, +see the Section 16.2. In order to quit out of vi, type the following:

+ + + + + +
+
+:q
+
+
+ +

Assuming that there have been no changes to the file, this will cause vi to quit. If there have been changes made, it will warn you that +there have been changes and tell you how to disregard them. Disregarding changes usually +means appending an exclamation point after the “q” like +so:

+ + + + + +
+
+:q!
+
+
+ +

The exclamation point usually means to force some action. We'll discuss it and other +key combinations in further details later.

+ +

You can also start vi with a pre-existing file. For example, +the file /etc/resolv.conf would be opened like so:

+ + + + + +
+
+% vi /etc/resolv.conf
+
+
+ +

Finally, vi can be started on a particular line of a file. +This is especially useful for programmers when an error message includes the line their +program bombed on. For example, you could start up vi on line 47 +of /usr/src/linux/init/main.c like so:

+ + + + + +
+
+% vi +47 /usr/src/linux/init/main.c
+
+
+ +

vi will display the given file and will place the cursor at +the specified line. In the case where you specify a line that is after the end of the +file, vi will place the cursor on the last line. This is +especially helpful for programmers, as they can jump straight to the location in the file +that an error occurred, without having to search for it.

+
+
+ + + + + -- cgit v1.2.3-65-gdbad