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