1 | <sect1 id="postlfs-config-vimrc" xreflabel="/etc/vimrc, ~/.vimrc">
|
---|
2 | <?dbhtml filename="vimrc.html" dir="postlfs"?>
|
---|
3 | <title>/etc/vimrc, ~/.vimrc</title>
|
---|
4 |
|
---|
5 | <para>The <acronym>LFS</acronym> book installs
|
---|
6 | <application>vim</application> as its editor. At this point we should
|
---|
7 | state that there are a <emphasis>lot</emphasis> of different editors out
|
---|
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
|
---|
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>
|
---|
33 |
|
---|
34 | <screen>" Begin .vimrc
|
---|
35 |
|
---|
36 | set bs=2
|
---|
37 | set columns=72
|
---|
38 | set background=dark
|
---|
39 | syntax on
|
---|
40 | set ruler
|
---|
41 |
|
---|
42 | " End .vimrc</screen>
|
---|
43 |
|
---|
44 | <para>A <acronym>FAQ</acronym> on the lfs mailing lists regards the
|
---|
45 | comment tags in <filename>vimrc</filename>. Note that they are " instead
|
---|
46 | of the more usual # or //. This is correct, the syntax for <filename>vimrc
|
---|
47 | </filename> is slightly unusual.</para>
|
---|
48 |
|
---|
49 | <para>We'll run through a quick explanation of what each of the
|
---|
50 | options in this example file means here:</para>
|
---|
51 | <itemizedlist>
|
---|
52 |
|
---|
53 | <listitem><para><userinput>set bs=2</userinput> : This influences the behavior
|
---|
54 | of the backspace option. It is fairly complex so see <userinput>:help 'bs'
|
---|
55 | </userinput> for more details.</para></listitem>
|
---|
56 |
|
---|
57 | <listitem><para><userinput>set columns=72</userinput> : This simply sets the
|
---|
58 | number of columns used on the screen.</para></listitem>
|
---|
59 |
|
---|
60 | <listitem><para><userinput>set background=dark</userinput> : This tells
|
---|
61 | <command>vim</command> to use colors which look good on a dark
|
---|
62 | background.</para></listitem>
|
---|
63 |
|
---|
64 | <listitem><para><userinput>syntax on</userinput> : Enables
|
---|
65 | <command>vim</command>'s syntax highlighting.</para></listitem>
|
---|
66 |
|
---|
67 | <listitem><para><userinput>set ruler</userinput> : This makes <command>vim
|
---|
68 | </command> show the current row and column at the bottom right of
|
---|
69 | the screen.</para></listitem>
|
---|
70 |
|
---|
71 |
|
---|
72 | </itemizedlist>
|
---|
73 |
|
---|
74 | <para>More information on the <emphasis>many</emphasis> <command>vim</command>
|
---|
75 | options can be found by reading the help inside <command>vim</command> itself.
|
---|
76 | Do this by typing <command>:</command><userinput>help</userinput> in
|
---|
77 | <command>vim</command> to get the general help, or by typing <command>:
|
---|
78 | </command><userinput>help usr_toc.txt</userinput> to view
|
---|
79 | the User Manual Table of Contents.</para>
|
---|
80 |
|
---|
81 | </sect1>
|
---|
82 |
|
---|