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>
|
---|
43 | <listitem><para><userinput>set nocompatible :</userinput>
|
---|
44 | This option stops vim from behaving in a strongly vi-compatible way. It
|
---|
45 | should be at the start of any vimrc file as it can affect lots of other
|
---|
46 | options which you may want to override.</para></listitem>
|
---|
47 |
|
---|
48 | <listitem><para><userinput>set bs=2 :</userinput>
|
---|
49 | This influences the behaviour of the backspace option. It is fairly
|
---|
50 | complex so see <userinput>:help 'bs'</userinput> for more
|
---|
51 | details.</para></listitem>
|
---|
52 |
|
---|
53 | <listitem><para><userinput>set columns=80 :</userinput>
|
---|
54 | This simply sets the number of columns used on the
|
---|
55 | screen.</para></listitem>
|
---|
56 |
|
---|
57 | <listitem><para><userinput>set background=dark :</userinput>
|
---|
58 | This tells vim to use colours which look good on a dark
|
---|
59 | background.</para></listitem>
|
---|
60 |
|
---|
61 | <listitem><para><userinput>set tabstop=8 :</userinput>
|
---|
62 | The number of spaces which a tabstop takes.</para></listitem>
|
---|
63 |
|
---|
64 | <listitem><para><userinput>set wrapmargin=8 :</userinput>
|
---|
65 | This is the number of characters from the right window
|
---|
66 | border where wrapping starts.</para></listitem>
|
---|
67 |
|
---|
68 | <listitem><para><userinput>set nobk :</userinput>
|
---|
69 | This stops vim from creating a backup before
|
---|
70 | overwriting a file.</para></listitem>
|
---|
71 |
|
---|
72 | <listitem><para><userinput>syntax on :</userinput>
|
---|
73 | Enables vim's syntax highlighting.</para></listitem>
|
---|
74 |
|
---|
75 | <listitem><para><userinput>set ruler :</userinput>
|
---|
76 | This makes vim show the current row and column at the bottom right of
|
---|
77 | the screen.</para></listitem>
|
---|
78 |
|
---|
79 | <listitem><para><userinput>set noexpandtab :</userinput>
|
---|
80 | This makes vim insert tabs as tab characters instead of as a set of
|
---|
81 | spaces.</para></listitem>
|
---|
82 |
|
---|
83 | </itemizedlist>
|
---|
84 |
|
---|
85 | <para>More information on the <emphasis>many</emphasis> vim options
|
---|
86 | can be found by reading the help inside vim itself. Do this by typing
|
---|
87 | <userinput>:help</userinput> in vim to get the general help, or by
|
---|
88 | typing <userinput>:help usr_toc.txt</userinput> to view the User Manual
|
---|
89 | Table of Contents.</para>
|
---|
90 |
|
---|
91 | </sect1>
|
---|
92 |
|
---|