[78b3cd61] | 1 | <sect1 id="postlfs-config-vimrc" xreflabel="/etc/vimrc, ~/.vimrc">
|
---|
[bae6e15] | 2 | <?dbhtml filename="vimrc.html"?>
|
---|
[f45b1953] | 3 | <title>/etc/vimrc, ~/.vimrc</title>
|
---|
| 4 |
|
---|
[1ea79a1] | 5 | <para>The <acronym>LFS</acronym> book installs <application>vim</application>
|
---|
| 6 | as its text editor. At this point we should state that there are a
|
---|
| 7 | <emphasis>lot</emphasis> of different editing applications out there including
|
---|
| 8 | <application>emacs</application>, <application>nano</application>,
|
---|
| 9 | <application>joe</application> and many more. Anyone who has been around the
|
---|
| 10 | Internet (especially usenet) for a short time will certainly have observed at
|
---|
| 11 | least one flame war, usually involving <application>vim</application> and
|
---|
[78b3cd61] | 12 | <application>emacs</application> users!</para>
|
---|
| 13 |
|
---|
| 14 | <para>The <acronym>LFS</acronym> book gives a basic <filename>vimrc
|
---|
| 15 | </filename> file. Here, we attempt to enhance this file. At startup,
|
---|
| 16 | <command>vim</command> reads <filename>/etc/vimrc</filename> and
|
---|
| 17 | <filename>~/.vimrc</filename> (i.e., the global
|
---|
| 18 | <filename>vimrc</filename> and the user-specific one.). Note that this is
|
---|
| 19 | only true if you compiled <application>vim</application> using
|
---|
| 20 | <acronym>LFS</acronym>-3.1 onwards. Prior to this,
|
---|
| 21 | the global <filename>vimrc</filename> was <filename>/usr/share/vim/vimrc
|
---|
| 22 | </filename>.</para>
|
---|
| 23 |
|
---|
| 24 | <para>Here is a slightly expanded <filename>vimrc</filename> that you can
|
---|
| 25 | put in <filename>/etc/vimrc</filename> to provide global effect. Of course, if
|
---|
[cfc2a54] | 26 | you put it into <filename>/etc/skel/.vimrc</filename> instead, it will
|
---|
| 27 | be made available to users you add to the system later. You can also copy
|
---|
| 28 | the file from <filename>/etc/skel/.vimrc</filename> to
|
---|
| 29 | <filename>/etc/vimrc</filename> and the home directory of users already
|
---|
[1ea79a1] | 30 | on the system, like root. Be sure to set permissions, owner, and group if
|
---|
[cfc2a54] | 31 | you do copy anything directly from <filename>/etc/skel</filename>.</para>
|
---|
[f45b1953] | 32 |
|
---|
[c442d19] | 33 | <screen>" Begin .vimrc
|
---|
[f45b1953] | 34 |
|
---|
[1cae4b1] | 35 | set nocompatible
|
---|
[f45b1953] | 36 | set bs=2
|
---|
[36ae4612] | 37 | set columns=80
|
---|
[f45b1953] | 38 | set background=dark
|
---|
[36ae4612] | 39 | set wrapmargin=8
|
---|
[f45b1953] | 40 | syntax on
|
---|
| 41 | set ruler
|
---|
| 42 |
|
---|
[c442d19] | 43 | " End .vimrc</screen>
|
---|
[f45b1953] | 44 |
|
---|
[78b3cd61] | 45 | <para>A <acronym>FAQ</acronym> on the lfs mailing lists regards the
|
---|
| 46 | comment tags in <filename>vimrc</filename>. Note that they are " instead
|
---|
| 47 | of the more usual # or //. This is correct, the syntax for <filename>vimrc
|
---|
| 48 | </filename> is slightly unusual.</para>
|
---|
[f45b1953] | 49 |
|
---|
| 50 | <para>We'll run through a quick explanation of what each of the
|
---|
| 51 | options in this example file means here:</para>
|
---|
| 52 | <itemizedlist>
|
---|
| 53 |
|
---|
[1cae4b1] | 54 | <listitem><para><option>set nocompatible</option> : This option
|
---|
| 55 | stops <command>vim</command> from behaving in a strongly <command>vi
|
---|
| 56 | </command>-compatible way. It should be at the start of any <filename>vimrc
|
---|
| 57 | </filename> file as it can affect lots of other options which you may want to
|
---|
| 58 | override.</para></listitem>
|
---|
| 59 |
|
---|
[2df36e4] | 60 | <listitem><para><option>set bs=2</option>: This influences the behavior
|
---|
[3df86b66] | 61 | of the backspace option. It is fairly complex so see <command>:help 'bs'
|
---|
| 62 | </command> for more details.</para></listitem>
|
---|
[f45b1953] | 63 |
|
---|
[2df36e4] | 64 | <listitem><para><option>set columns=80</option>: This simply sets the
|
---|
[78b3cd61] | 65 | number of columns used on the screen.</para></listitem>
|
---|
[f45b1953] | 66 |
|
---|
[2df36e4] | 67 | <listitem><para><option>set background=dark</option>: This tells
|
---|
[78b3cd61] | 68 | <command>vim</command> to use colors which look good on a dark
|
---|
[f45b1953] | 69 | background.</para></listitem>
|
---|
| 70 |
|
---|
[2df36e4] | 71 | <listitem><para><option>set wrapmargin=8</option>: This is the number of
|
---|
[36ae4612] | 72 | characters from the right window border where wrapping starts.</para>
|
---|
| 73 | </listitem>
|
---|
| 74 |
|
---|
[2df36e4] | 75 | <listitem><para><option>syntax on</option>: Enables
|
---|
[78b3cd61] | 76 | <command>vim</command>'s syntax highlighting.</para></listitem>
|
---|
[f45b1953] | 77 |
|
---|
[2df36e4] | 78 | <listitem><para><option>set ruler</option>: This makes <command>vim
|
---|
[78b3cd61] | 79 | </command> show the current row and column at the bottom right of
|
---|
[f45b1953] | 80 | the screen.</para></listitem>
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | </itemizedlist>
|
---|
| 84 |
|
---|
[78b3cd61] | 85 | <para>More information on the <emphasis>many</emphasis> <command>vim</command>
|
---|
| 86 | options can be found by reading the help inside <command>vim</command> itself.
|
---|
[3df86b66] | 87 | Do this by typing <command>:</command><option>help</option> in
|
---|
[78b3cd61] | 88 | <command>vim</command> to get the general help, or by typing <command>:
|
---|
[3df86b66] | 89 | </command><option>help usr_toc.txt</option> to view
|
---|
[78b3cd61] | 90 | the User Manual Table of Contents.</para>
|
---|
[f45b1953] | 91 |
|
---|
| 92 | </sect1>
|
---|
| 93 |
|
---|