[f8d632ac] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[f8d632ac] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
[0290a023] | 8 | <sect1 id="postlfs-config-vimrc" xreflabel="The vimrc Files">
|
---|
[1cb62b2] | 9 | <?dbhtml filename="vimrc.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>The /etc/vimrc and ~/.vimrc Files</title>
|
---|
| 17 |
|
---|
| 18 | <indexterm zone="postlfs-config-vimrc">
|
---|
| 19 | <primary sortas="e-etc-vimrc">/etc/vimrc</primary>
|
---|
| 20 | </indexterm>
|
---|
| 21 |
|
---|
| 22 | <indexterm zone="postlfs-config-vimrc">
|
---|
| 23 | <primary sortas="e-AA.vimrc">~/.vimrc</primary>
|
---|
| 24 | </indexterm>
|
---|
| 25 |
|
---|
| 26 | <para>The LFS book installs <application>Vim</application>
|
---|
[615b431] | 27 | as its text editor. At this point it should be noted that there are a
|
---|
[1cb62b2] | 28 | <emphasis>lot</emphasis> of different editing applications out there including
|
---|
| 29 | <application>Emacs</application>, <application>nano</application>,
|
---|
| 30 | <application>Joe</application> and many more. Anyone who has been around the
|
---|
| 31 | Internet (especially usenet) for a short time will certainly have observed at
|
---|
| 32 | least one flame war, usually involving <application>Vim</application> and
|
---|
| 33 | <application>Emacs</application> users!</para>
|
---|
| 34 |
|
---|
[615b431] | 35 | <para>The LFS book creates a basic <filename>vimrc</filename> file. In this
|
---|
| 36 | section you'll find an attempt to enhance this file. At startup,
|
---|
[ffe4d4ae] | 37 | <command>vim</command> reads the global configuration file
|
---|
| 38 | (<filename>/etc/vimrc</filename>) as well as a user-specific file
|
---|
| 39 | (<filename>~/.vimrc</filename>). Either or both can be tailored to suit
|
---|
| 40 | the needs of your particular system.</para>
|
---|
[1cb62b2] | 41 |
|
---|
[e0d33ef] | 42 | <para>Here is a slightly expanded <filename>.vimrc</filename> that you can
|
---|
| 43 | put in <filename>~/.vimrc</filename> to provide user specific effects. Of
|
---|
| 44 | course, if you put it into <filename>/etc/skel/.vimrc</filename> instead, it
|
---|
[1cb62b2] | 45 | will be made available to users you add to the system later. You can also copy
|
---|
[e0d33ef] | 46 | the file from <filename>/etc/skel/.vimrc</filename> to the home directory of
|
---|
[615b431] | 47 | users already on the system, such as
|
---|
| 48 | <systemitem class='username'>root</systemitem>. Be sure to set permissions,
|
---|
| 49 | owner, and group if you do copy anything directly from
|
---|
[1cb62b2] | 50 | <filename class="directory">/etc/skel</filename>.</para>
|
---|
| 51 |
|
---|
| 52 | <screen><literal>" Begin .vimrc
|
---|
[f45b1953] | 53 |
|
---|
[36ae4612] | 54 | set columns=80
|
---|
| 55 | set wrapmargin=8
|
---|
[f45b1953] | 56 | set ruler
|
---|
| 57 |
|
---|
[1cb62b2] | 58 | " End .vimrc</literal></screen>
|
---|
| 59 |
|
---|
[6c63b55] | 60 | <para>Note that the comment tags are " instead of the more
|
---|
[e0d33ef] | 61 | usual # or //. This is correct, the syntax for
|
---|
[1cb62b2] | 62 | <filename>vimrc</filename> is slightly unusual.</para>
|
---|
| 63 |
|
---|
[615b431] | 64 | <para>Below you'll find a quick explanation of what each of the
|
---|
[1cb62b2] | 65 | options in this example file means here:</para>
|
---|
| 66 |
|
---|
| 67 | <itemizedlist>
|
---|
[e0d33ef] | 68 | <!--
|
---|
[1cb62b2] | 69 | <listitem>
|
---|
| 70 | <para><option>set nocompatible</option> : This option
|
---|
| 71 | stops <command>vim</command> from behaving in a strongly <command>vi
|
---|
| 72 | </command>-compatible way. It should be at the start of any <filename>vimrc
|
---|
| 73 | </filename> file as it can affect lots of other options which you may want to
|
---|
| 74 | override.</para>
|
---|
| 75 | </listitem>
|
---|
| 76 | <listitem>
|
---|
[e0d33ef] | 77 | <para><option>set bs=2</option>: This influences the behavior
|
---|
[1cb62b2] | 78 | of the backspace option. It is fairly complex so see <command>:help 'bs'
|
---|
| 79 | </command> for more details.</para>
|
---|
[d612b9f] | 80 | </listitem>
|
---|
[1cb62b2] | 81 | -->
|
---|
| 82 | <listitem>
|
---|
[e0d33ef] | 83 | <para><option>set columns=80</option>: This simply sets the
|
---|
[1cb62b2] | 84 | number of columns used on the screen.</para>
|
---|
| 85 | </listitem>
|
---|
[e0d33ef] | 86 | <!--
|
---|
[1cb62b2] | 87 | <listitem>
|
---|
| 88 | <para><option>set background=dark</option>: This tells
|
---|
[e0d33ef] | 89 | <command>vim</command> to use colors which look good on a dark
|
---|
[1cb62b2] | 90 | background.</para>
|
---|
[d612b9f] | 91 | </listitem>
|
---|
[1cb62b2] | 92 | -->
|
---|
| 93 | <listitem>
|
---|
[e0d33ef] | 94 | <para><option>set wrapmargin=8</option>: This is the number of
|
---|
[1cb62b2] | 95 | characters from the right window border where wrapping starts.</para>
|
---|
| 96 | </listitem>
|
---|
[e0d33ef] | 97 | <!--
|
---|
[1cb62b2] | 98 | <listitem>
|
---|
| 99 | <para><option>syntax on</option>: Enables
|
---|
| 100 | <command>vim</command>'s syntax highlighting.</para>
|
---|
| 101 | </listitem>
|
---|
| 102 | -->
|
---|
| 103 | <listitem>
|
---|
[d612b9f] | 104 | <para><option>set ruler</option>: This makes <command>vim</command>
|
---|
[1cb62b2] | 105 | show the current row and column at the bottom right of the screen.</para>
|
---|
| 106 | </listitem>
|
---|
| 107 | </itemizedlist>
|
---|
| 108 |
|
---|
[d612b9f] | 109 | <para>More information on the <emphasis>many</emphasis>
|
---|
[e0d33ef] | 110 | <command>vim</command> options can be found by reading the help
|
---|
| 111 | inside <command>vim</command> itself. Do this by typing
|
---|
| 112 | <command>:</command><option>help</option> in
|
---|
| 113 | <command>vim</command> to get the general help, or by typing
|
---|
| 114 | <command>:</command><option>help usr_toc.txt</option> to view
|
---|
[1cb62b2] | 115 | the User Manual Table of Contents.</para>
|
---|
[f45b1953] | 116 |
|
---|
| 117 | </sect1>
|
---|