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