[f8d632ac] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[ff769b8c] | 2 | <!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/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,
|
---|
| 37 | <command>vim</command> reads <filename>/etc/vimrc</filename> and
|
---|
| 38 | <filename>~/.vimrc</filename> (i.e., the global <filename>vimrc</filename>
|
---|
| 39 | and the user-specific one). Note that this is only true if you compiled
|
---|
| 40 | <application>vim</application> using LFS-3.1 onwards. Prior to this, the
|
---|
| 41 | global <filename>vimrc</filename> was
|
---|
[1cb62b2] | 42 | <filename>/usr/share/vim/vimrc</filename>.</para>
|
---|
| 43 |
|
---|
[e0d33ef] | 44 | <para>Here is a slightly expanded <filename>.vimrc</filename> that you can
|
---|
| 45 | put in <filename>~/.vimrc</filename> to provide user specific effects. Of
|
---|
| 46 | course, if you put it into <filename>/etc/skel/.vimrc</filename> instead, it
|
---|
[1cb62b2] | 47 | will be made available to users you add to the system later. You can also copy
|
---|
[e0d33ef] | 48 | the file from <filename>/etc/skel/.vimrc</filename> to the home directory of
|
---|
[615b431] | 49 | users already on the system, such as
|
---|
| 50 | <systemitem class='username'>root</systemitem>. Be sure to set permissions,
|
---|
| 51 | owner, and group if you do copy anything directly from
|
---|
[1cb62b2] | 52 | <filename class="directory">/etc/skel</filename>.</para>
|
---|
| 53 |
|
---|
| 54 | <screen><literal>" Begin .vimrc
|
---|
[f45b1953] | 55 |
|
---|
[36ae4612] | 56 | set columns=80
|
---|
| 57 | set wrapmargin=8
|
---|
[f45b1953] | 58 | set ruler
|
---|
| 59 |
|
---|
[1cb62b2] | 60 | " End .vimrc</literal></screen>
|
---|
| 61 |
|
---|
[e0d33ef] | 62 | <para>A FAQ on the LFS mailing lists regards the comment tags in
|
---|
| 63 | <filename>vimrc</filename>. Note that they are " instead of the more
|
---|
| 64 | usual # or //. This is correct, the syntax for
|
---|
[1cb62b2] | 65 | <filename>vimrc</filename> is slightly unusual.</para>
|
---|
| 66 |
|
---|
[615b431] | 67 | <para>Below you'll find a quick explanation of what each of the
|
---|
[1cb62b2] | 68 | options in this example file means here:</para>
|
---|
| 69 |
|
---|
| 70 | <itemizedlist>
|
---|
[e0d33ef] | 71 | <!--
|
---|
[1cb62b2] | 72 | <listitem>
|
---|
| 73 | <para><option>set nocompatible</option> : This option
|
---|
| 74 | stops <command>vim</command> from behaving in a strongly <command>vi
|
---|
| 75 | </command>-compatible way. It should be at the start of any <filename>vimrc
|
---|
| 76 | </filename> file as it can affect lots of other options which you may want to
|
---|
| 77 | override.</para>
|
---|
| 78 | </listitem>
|
---|
| 79 | <listitem>
|
---|
[e0d33ef] | 80 | <para><option>set bs=2</option>: This influences the behavior
|
---|
[1cb62b2] | 81 | of the backspace option. It is fairly complex so see <command>:help 'bs'
|
---|
| 82 | </command> for more details.</para>
|
---|
[d612b9f] | 83 | </listitem>
|
---|
[1cb62b2] | 84 | -->
|
---|
| 85 | <listitem>
|
---|
[e0d33ef] | 86 | <para><option>set columns=80</option>: This simply sets the
|
---|
[1cb62b2] | 87 | number of columns used on the screen.</para>
|
---|
| 88 | </listitem>
|
---|
[e0d33ef] | 89 | <!--
|
---|
[1cb62b2] | 90 | <listitem>
|
---|
| 91 | <para><option>set background=dark</option>: This tells
|
---|
[e0d33ef] | 92 | <command>vim</command> to use colors which look good on a dark
|
---|
[1cb62b2] | 93 | background.</para>
|
---|
[d612b9f] | 94 | </listitem>
|
---|
[1cb62b2] | 95 | -->
|
---|
| 96 | <listitem>
|
---|
[e0d33ef] | 97 | <para><option>set wrapmargin=8</option>: This is the number of
|
---|
[1cb62b2] | 98 | characters from the right window border where wrapping starts.</para>
|
---|
| 99 | </listitem>
|
---|
[e0d33ef] | 100 | <!--
|
---|
[1cb62b2] | 101 | <listitem>
|
---|
| 102 | <para><option>syntax on</option>: Enables
|
---|
| 103 | <command>vim</command>'s syntax highlighting.</para>
|
---|
| 104 | </listitem>
|
---|
| 105 | -->
|
---|
| 106 | <listitem>
|
---|
[d612b9f] | 107 | <para><option>set ruler</option>: This makes <command>vim</command>
|
---|
[1cb62b2] | 108 | show the current row and column at the bottom right of the screen.</para>
|
---|
| 109 | </listitem>
|
---|
| 110 | </itemizedlist>
|
---|
| 111 |
|
---|
[d612b9f] | 112 | <para>More information on the <emphasis>many</emphasis>
|
---|
[e0d33ef] | 113 | <command>vim</command> options can be found by reading the help
|
---|
| 114 | inside <command>vim</command> itself. Do this by typing
|
---|
| 115 | <command>:</command><option>help</option> in
|
---|
| 116 | <command>vim</command> to get the general help, or by typing
|
---|
| 117 | <command>:</command><option>help usr_toc.txt</option> to view
|
---|
[1cb62b2] | 118 | the User Manual Table of Contents.</para>
|
---|
[f45b1953] | 119 |
|
---|
| 120 | </sect1>
|
---|