2003-09-22 00:44:58 +08:00
|
|
|
<sect1 id="postlfs-config-vimrc" xreflabel="/etc/vimrc, ~/.vimrc">
|
2002-07-08 04:28:42 +08:00
|
|
|
<?dbhtml filename="vimrc.html" dir="postlfs"?>
|
|
|
|
<title>/etc/vimrc, ~/.vimrc</title>
|
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<para>The <acronym>LFS</acronym> book installs
|
|
|
|
<application>vim</application> as its editor. At this point we should
|
2002-07-08 04:28:42 +08:00
|
|
|
state that there are a <emphasis>lot</emphasis> of different editors out
|
2003-09-22 00:44:58 +08:00
|
|
|
there including <application>emacs</application>,
|
|
|
|
<application>nano</application>, <application>joe</application> and many
|
|
|
|
more. Anyone who has been around the Internet (especially usenet) for a
|
|
|
|
short time will certainly have observed at least one flame war, usually
|
|
|
|
involving <application>vim</application> and
|
|
|
|
<application>emacs</application> users!</para>
|
|
|
|
|
|
|
|
<para>The <acronym>LFS</acronym> book gives a basic <filename>vimrc
|
|
|
|
</filename> file. Here, we attempt to enhance this file. At startup,
|
|
|
|
<command>vim</command> reads <filename>/etc/vimrc</filename> and
|
|
|
|
<filename>~/.vimrc</filename> (i.e., the global
|
|
|
|
<filename>vimrc</filename> and the user-specific one.). Note that this is
|
|
|
|
only true if you compiled <application>vim</application> using
|
|
|
|
<acronym>LFS</acronym>-3.1 onwards. Prior to this,
|
|
|
|
the global <filename>vimrc</filename> was <filename>/usr/share/vim/vimrc
|
|
|
|
</filename>.</para>
|
|
|
|
|
|
|
|
<para>Here is a slightly expanded <filename>vimrc</filename> that you can
|
|
|
|
put in <filename>/etc/vimrc</filename> to provide global effect. Of course, if
|
2003-08-22 23:37:27 +08:00
|
|
|
you put it into <filename>/etc/skel/.vimrc</filename> instead, it will
|
|
|
|
be made available to users you add to the system later. You can also copy
|
|
|
|
the file from <filename>/etc/skel/.vimrc</filename> to
|
|
|
|
<filename>/etc/vimrc</filename> and the home directory of users already
|
|
|
|
on the system, like root. Be sure to set permissions, owner and group if
|
|
|
|
you do copy anything directly from <filename>/etc/skel</filename>.</para>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
2003-09-24 00:38:50 +08:00
|
|
|
<screen>" Begin .vimrc
|
2002-07-08 04:28:42 +08:00
|
|
|
|
|
|
|
set bs=2
|
2003-09-28 22:59:29 +08:00
|
|
|
set columns=80
|
2002-07-08 04:28:42 +08:00
|
|
|
set background=dark
|
2003-09-28 22:59:29 +08:00
|
|
|
set wrapmargin=8
|
2002-07-08 04:28:42 +08:00
|
|
|
syntax on
|
|
|
|
set ruler
|
|
|
|
|
2003-09-24 00:38:50 +08:00
|
|
|
" End .vimrc</screen>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<para>A <acronym>FAQ</acronym> on the lfs mailing lists regards the
|
|
|
|
comment tags in <filename>vimrc</filename>. Note that they are " instead
|
|
|
|
of the more usual # or //. This is correct, the syntax for <filename>vimrc
|
|
|
|
</filename> is slightly unusual.</para>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
|
|
|
<para>We'll run through a quick explanation of what each of the
|
|
|
|
options in this example file means here:</para>
|
|
|
|
<itemizedlist>
|
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<listitem><para><userinput>set bs=2</userinput> : This influences the behavior
|
|
|
|
of the backspace option. It is fairly complex so see <userinput>:help 'bs'
|
|
|
|
</userinput> for more details.</para></listitem>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
2003-09-28 22:59:29 +08:00
|
|
|
<listitem><para><userinput>set columns=80</userinput> : This simply sets the
|
2003-09-22 00:44:58 +08:00
|
|
|
number of columns used on the screen.</para></listitem>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<listitem><para><userinput>set background=dark</userinput> : This tells
|
|
|
|
<command>vim</command> to use colors which look good on a dark
|
2002-07-08 04:28:42 +08:00
|
|
|
background.</para></listitem>
|
|
|
|
|
2003-09-28 22:59:29 +08:00
|
|
|
<listitem><para><userinput>set wrapmargin=8</userinput> : This is the number of
|
|
|
|
characters from the right window border where wrapping starts.</para>
|
|
|
|
</listitem>
|
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<listitem><para><userinput>syntax on</userinput> : Enables
|
|
|
|
<command>vim</command>'s syntax highlighting.</para></listitem>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<listitem><para><userinput>set ruler</userinput> : This makes <command>vim
|
|
|
|
</command> show the current row and column at the bottom right of
|
2002-07-08 04:28:42 +08:00
|
|
|
the screen.</para></listitem>
|
|
|
|
|
|
|
|
|
|
|
|
</itemizedlist>
|
|
|
|
|
2003-09-22 00:44:58 +08:00
|
|
|
<para>More information on the <emphasis>many</emphasis> <command>vim</command>
|
|
|
|
options can be found by reading the help inside <command>vim</command> itself.
|
|
|
|
Do this by typing <command>:</command><userinput>help</userinput> in
|
|
|
|
<command>vim</command> to get the general help, or by typing <command>:
|
|
|
|
</command><userinput>help usr_toc.txt</userinput> to view
|
|
|
|
the User Manual Table of Contents.</para>
|
2002-07-08 04:28:42 +08:00
|
|
|
|
|
|
|
</sect1>
|
|
|
|
|