[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 |
|
---|
| 19 | <para>Here is an example of a slightly expanded vimrc:</para>
|
---|
| 20 |
|
---|
| 21 | <para><screen>" Begin .vimrc
|
---|
| 22 |
|
---|
| 23 | set nocompatible
|
---|
| 24 | set bs=2
|
---|
| 25 | set columns=80
|
---|
| 26 | set background=dark
|
---|
| 27 | set tabstop=8
|
---|
| 28 | set wrapmargin=8
|
---|
| 29 | set nobk
|
---|
| 30 | syntax on
|
---|
| 31 | set ruler
|
---|
| 32 | set noexpandtab
|
---|
| 33 |
|
---|
| 34 | " End .vimrc</screen></para>
|
---|
| 35 |
|
---|
| 36 | <para>A FAQ on the lfs lists regards the comment tags in vimrc. Note
|
---|
| 37 | that they are " instead of the more usual # or //. This is correct, the
|
---|
| 38 | syntax for vimrc is slightly unusual.</para>
|
---|
| 39 |
|
---|
| 40 | <para>We'll run through a quick explanation of what each of the
|
---|
| 41 | options in this example file means here:</para>
|
---|
| 42 | <itemizedlist>
|
---|
[01600b9] | 43 | <listitem><para><userinput>set nocompatible</userinput> : This option stops vim from behaving in a strongly vi-compatible way. It
|
---|
[f45b1953] | 44 | should be at the start of any vimrc file as it can affect lots of other
|
---|
| 45 | options which you may want to override.</para></listitem>
|
---|
| 46 |
|
---|
[01600b9] | 47 | <listitem><para><userinput>set bs=2</userinput> : This influences the behavior of the backspace option. It is fairly
|
---|
[f45b1953] | 48 | complex so see <userinput>:help 'bs'</userinput> for more
|
---|
| 49 | details.</para></listitem>
|
---|
| 50 |
|
---|
[01600b9] | 51 | <listitem><para><userinput>set columns=80</userinput> : This simply sets the number of columns used on the
|
---|
[f45b1953] | 52 | screen.</para></listitem>
|
---|
| 53 |
|
---|
[01600b9] | 54 | <listitem><para><userinput>set background=dark</userinput> : This tells vim to use colors which look good on a dark
|
---|
[f45b1953] | 55 | background.</para></listitem>
|
---|
| 56 |
|
---|
[01600b9] | 57 | <listitem><para><userinput>set tabstop=8</userinput> : The number of spaces which a tabstop takes.</para></listitem>
|
---|
[f45b1953] | 58 |
|
---|
[01600b9] | 59 | <listitem><para><userinput>set wrapmargin=8</userinput> : This is the number of characters from the right window
|
---|
[f45b1953] | 60 | border where wrapping starts.</para></listitem>
|
---|
| 61 |
|
---|
[01600b9] | 62 | <listitem><para><userinput>set nobk</userinput> : This stops vim from creating a backup before
|
---|
[f45b1953] | 63 | overwriting a file.</para></listitem>
|
---|
| 64 |
|
---|
[01600b9] | 65 | <listitem><para><userinput>syntax on</userinput> : Enables vim's syntax highlighting.</para></listitem>
|
---|
[f45b1953] | 66 |
|
---|
[01600b9] | 67 | <listitem><para><userinput>set ruler</userinput> : This makes vim show the current row and column at the bottom right of
|
---|
[f45b1953] | 68 | the screen.</para></listitem>
|
---|
| 69 |
|
---|
[01600b9] | 70 | <listitem><para><userinput>set noexpandtab</userinput> : This makes vim insert tabs as tab characters instead of as a set of
|
---|
[f45b1953] | 71 | spaces.</para></listitem>
|
---|
| 72 |
|
---|
| 73 | </itemizedlist>
|
---|
| 74 |
|
---|
| 75 | <para>More information on the <emphasis>many</emphasis> vim options
|
---|
| 76 | can be found by reading the help inside vim itself. Do this by typing
|
---|
| 77 | <userinput>:help</userinput> in vim to get the general help, or by
|
---|
| 78 | typing <userinput>:help usr_toc.txt</userinput> to view the User Manual
|
---|
| 79 | Table of Contents.</para>
|
---|
| 80 |
|
---|
| 81 | </sect1>
|
---|
| 82 |
|
---|