aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06/vim.xml
blob: ed5448187eda53b745783672ed5dccdda5688a11 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-vim" role="wrap">
  <?dbhtml filename="vim.html"?>

  <sect1info condition="script">
    <productname>vim</productname>
    <productnumber>&vim-version;</productnumber>
    <address>&vim-url;<otheraddr>&vim-lang-url;</otheraddr></address>
  </sect1info>

  <title>Vim-&vim-version;</title>

  <indexterm zone="ch-system-vim">
    <primary sortas="a-Vim">Vim</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

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

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&vim-ch6-sbu;</seg>
        <seg>&vim-ch6-du;</seg>
      </seglistitem>
    </segmentedlist>

    <tip>
      <title>Alternatives to Vim</title>

      <para>If you prefer another editor&mdash;such as Emacs, Joe, or
      Nano&mdash;please refer to <ulink
      url="&blfs-root;view/svn/postlfs/editors.html"/> for suggested
      installation instructions.</para>
    </tip>

  </sect2>

  <sect2 role="installation">
    <title>Installation of Vim</title>

    <para>First, unpack both
    <filename>vim-&vim-version;.tar.bz2</filename> and (optionally)
    <filename>vim-&vim-version;-lang.tar.gz</filename> archives into the
    same directory.</para>

    <para>Apply a patch which fixes various issues already found and fixed by
    the upstream maintainers since the inital release of Vim-&vim-version;:
    </para>

<screen><userinput remap="pre">patch -Np1 -i ../&vim-fixes-patch;</userinput></screen>

    <para>This version of Vim installs translated man pages and places
    them into directories that will not be searched by Man-DB. Patch Vim
    so that it installs its man pages into searchable directories and
    ultimately allows Man-DB to transcode the page into the desired format
    at run-time:</para>

<screen><userinput remap="pre">patch -Np1 -i ../&vim-mandir-patch;</userinput></screen>

    <para>Change the default location of the
    <filename>vimrc</filename> configuration file to <filename
    class="directory">/etc</filename>:</para>

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

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

<screen><userinput remap="configure">./configure --prefix=/usr --enable-multibyte</userinput></screen>

    <variablelist>
      <title>The meaning of the configure options:</title>

      <varlistentry>
        <term><parameter>--enable-multibyte</parameter></term>
        <listitem>
          <para>This switch enables support for editing files in multibyte
          character encodings.  This is needed if using a locale with a
          multibyte character set. This switch is also helpful to be able
          to edit text files initially created in Linux distributions like
          Fedora Core that use UTF-8 as a default character set.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>Compile the package:</para>

<screen><userinput remap="make">make</userinput></screen>

    <para>To test the results, issue:</para>

<screen><userinput remap="test">make test</userinput></screen>

    <para>However, this test suite outputs a lot of binary data to the screen,
    which can cause issues with the settings of the current terminal. This can
    be resolved by redirecting the output to a log file.</para>

    <para>Install the package:</para>

<screen><userinput remap="install">make install</userinput></screen>

    <para>Many users are used to using <command>vi</command> instead of
    <command>vim</command>. To allow execution of <command>vim</command>
    when users habitually enter <command>vi</command>, create a
    symlink for both the binary and the man page in the provided
    languages:</para>

<screen><userinput remap="install">ln -sv vim /usr/bin/vi
for L in  /usr/share/man/{,*/}man1/vim.1; do
    ln -sv vim.1 $(dirname $L)/vi.1
done</userinput></screen>

    <para>By default, Vim's documentation is installed in <filename
    class="directory">/usr/share/vim</filename>. The following symlink
    allows the documentation to be accessed via <filename
    class="directory">/usr/share/doc/vim-&vim-version;</filename>, making
    it consistent with the location of documentation for other packages:</para>

<screen><userinput remap="install">ln -sv ../&vim-docdir;/doc /usr/share/doc/vim-&vim-version;</userinput></screen>

    <para>If an X Window System is going to be installed on the LFS
    system, it may be necessary to recompile Vim after installing X. Vim
    comes with a GUI version of the editor that requires X and some
    additional libraries to be installed. For more information on this
    process, refer to the Vim documentation and the Vim installation page
    in the BLFS book at <ulink
    url="&blfs-root;view/svn/postlfs/editors.html#postlfs-editors-vim"/>.</para>

  </sect2>

  <sect2 id="conf-vim" role="configuration">
    <title>Configuring Vim</title>

    <indexterm zone="conf-vim">
      <primary sortas="e-/etc/vimrc">/etc/vimrc</primary>
    </indexterm>

    <para>By default, <command>vim</command> runs in vi-incompatible mode.
    This may be new to users who have used other editors in the past. The
    <quote>nocompatible</quote> setting is included below to highlight the
    fact that a new behavior is being used. It also reminds those who would
    change to <quote>compatible</quote> mode that it should be the first
    setting in the configuration file. This is necessary because it changes
    other settings, and overrides must come after this setting. Create a default
    <command>vim</command> configuration file by running the following:</para>

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

set nocompatible
set backspace=2
syntax on
if (&amp;term == "iterm") || (&amp;term == "putty")
  set background=dark
endif

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

    <para>The <parameter>set nocompatible</parameter> setting makes
    <command>vim</command> behave in a more useful way (the default) than
    the vi-compatible manner. Remove the <quote>no</quote> to keep the
    old <command>vi</command> behavior. The <parameter>set
    backspace=2</parameter> setting allows backspacing over line breaks,
    autoindents, and the start of insert. The <parameter>syntax
    on</parameter> parameter enables vim's syntax highlighting. Finally,
    the <emphasis>if</emphasis> statement with the <parameter>set
    background=dark</parameter> setting corrects <command>vim</command>'s
    guess about the background color of some terminal emulators. This
    gives the highlighting a better color scheme for use on the black
    background of these programs.</para>

    <para>Documentation for other available options can be obtained by
    running the following command:</para>

<screen role="nodump"><userinput>vim -c ':options'</userinput></screen>

    <note>
      <para>By default, Vim only installs spell files for the English language.
      To install spell files for your preferred language, download the
      <filename>*.spl</filename> and optionally, the <filename>*.sug</filename>
      files for your language and character encoding from <ulink
      url="ftp://ftp.vim.org/pub/vim/runtime/spell/"/> and save them to
      <filename class='directory'>/usr/share/&vim-docdir;/spell/</filename>.</para>

      <para>To use these spell files, some configuration in
      <filename>/etc/vimrc</filename> is needed, e.g.:</para>

<screen><literal>set spelllang=en,ru
set spell</literal></screen>

      <para>For more information, see the appropriate README file located
      at the URL above.</para>
    </note>

  </sect2>

  <sect2 id="contents-vim" role="content">
    <title>Contents of Vim</title>

    <segmentedlist>
      <segtitle>Installed programs</segtitle>

      <seglistitem>
        <seg>ex (link to vim), rview (link to vim), rvim (link to vim), 
        vi (link to vim), view (link to vim), vim, 
        vimdiff (link to vim), vimtutor, and xxd</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="ex">
        <term><command>ex</command></term>
        <listitem>
          <para>Starts <command>vim</command> in ex mode</para>
          <indexterm zone="ch-system-vim ex">
            <primary sortas="b-ex">ex</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="rview">
        <term><command>rview</command></term>
        <listitem>
          <para>Is a restricted version of <command>view</command>; no shell
          commands can be started and <command>view</command> cannot be
          suspended</para>
          <indexterm zone="ch-system-vim rview">
            <primary sortas="b-rview">rview</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="rvim">
        <term><command>rvim</command></term>
        <listitem>
          <para>Is a restricted version of <command>vim</command>; no shell
          commands can be started and <command>vim</command> cannot be
          suspended</para>
          <indexterm zone="ch-system-vim rvim">
            <primary sortas="b-rvim">rvim</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="vi">
        <term><command>vi</command></term>
        <listitem>
          <para>Link to <command>vim</command></para>
          <indexterm zone="ch-system-vim vi">
            <primary sortas="b-vi">vi</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="view">
        <term><command>view</command></term>
        <listitem>
          <para>Starts <command>vim</command> in read-only mode</para>
          <indexterm zone="ch-system-vim view">
            <primary sortas="b-view">view</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="vim">
        <term><command>vim</command></term>
        <listitem>
          <para>Is the editor</para>
          <indexterm zone="ch-system-vim vim">
            <primary sortas="b-vim">vim</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="vimdiff">
        <term><command>vimdiff</command></term>
        <listitem>
          <para>Edits two or three versions of a file with <command>vim</command>
          and show differences</para>
          <indexterm zone="ch-system-vim vimdiff">
            <primary sortas="b-vimdiff">vimdiff</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="vimtutor">
        <term><command>vimtutor</command></term>
        <listitem>
          <para>Teaches the basic keys and commands of
          <command>vim</command></para>
          <indexterm zone="ch-system-vim vimtutor">
            <primary sortas="b-vimtutor">vimtutor</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="xxd">
        <term><command>xxd</command></term>
        <listitem>
          <para>Creates a hex dump of the given file; it can
          also do the reverse, so it can be used for binary patching</para>
          <indexterm zone="ch-system-vim xxd">
            <primary sortas="b-xxd">xxd</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>