aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06/vim.xml
blob: 272b1f4cf94b3e6369e847a09917a44156feb761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<sect1 id="ch-system-vim" xreflabel="Vim">
<title>Installing Vim-&vim-version;</title>
<?dbhtml filename="vim.html" dir="chapter06"?>

<para>The Vim package contains a powerful text editor.</para>

<screen>&buildtime; &vim-time;
&diskspace; &vim-compsize;</screen>

&aa-vim-down;
&aa-vim-dep;

<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>

<sect2>
<title>Alternatives to Vim</title>
<para>If you prefer another editor -- like Emacs, Joe, or Nano -- to Vim,
have a look at <ulink url="&blfs-root;view/stable/postlfs/editors.html"/> for
suggested installation instructions.</para>
</sect2>

<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>

<sect2>
<title>Installation of Vim</title>

<para>First change the default locations of the <filename>vimrc</filename> and
<filename>gvimrc</filename> configuration files to <filename
class="directory">/etc</filename>.</para>

<screen><userinput>echo '#define SYS_VIMRC_FILE "/etc/vimrc"' &gt;&gt; src/feature.h
echo '#define SYS_GVIMRC_FILE "/etc/gvimrc"' &gt;&gt; src/feature.h</userinput></screen>

<para>Now prepare Vim for compilation:</para>

<screen><userinput>./configure --prefix=/usr</userinput></screen>

<para>Compile the package:</para>

<screen><userinput>make</userinput></screen>

<para>To have the results tested, you can issue:
<userinput>make check</userinput>. However, this test suite outputs a lot of
seemingly garbage characters to the screen, and this can wreak havoc with the
settings of the current terminal. Therefore the running of the test suite here
is strictly optional.</para>

<para>And install the package:</para>

<screen><userinput>make install</userinput></screen>

<para>When called as <command>vi</command>, <command>vim</command>
will run in old-fashioned vi-mode. To allow this, create a symlink:</para>

<screen><userinput>ln -s vim /usr/bin/vi</userinput></screen>

<para>If you are going to install the X Window system on your LFS system, you
may want to re-compile Vim after having installed X. Vim comes with a nice GUI
version of the editor that requires X and a few other libraries to be
installed. For more information read the Vim documentation.</para>

</sect2>

<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>

<sect2><title>Configuring Vim</title>

<para>By default, <command>vim</command> runs in vi-compatible mode. Some
people might like this, but we prefer to run <command>vim</command> in its
own mode (else we wouldn't have included it in this book, but the original
<command>vi</command>). Create a default vim configuration file by running
the following:</para>

<screen><userinput>cat &gt; /etc/vimrc &lt;&lt; "EOF"</userinput>
" Begin /etc/vimrc

set nocompatible
set backspace=2
syntax on

" End /etc/vimrc
<userinput>EOF</userinput></screen>

<para>The <emphasis>set nocompatible</emphasis> will make
<command>vim</command> behave in a more useful way than the default
vi-compatible manner. The <emphasis>set backspace=2</emphasis> allows
backspacing over line breaks, autoindent and the start of insert. And the
<emphasis>syntax on</emphasis> switches on <command>vim</command>'s
semantic colouring.</para>

</sect2>

&aa-vim-shortdesc;
&aa-vim-desc;

</sect1>