vim.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-vim" role="wrap">
  8. <?dbhtml filename="vim.html"?>
  9. <sect1info condition="script">
  10. <productname>vim</productname>
  11. <productnumber>&vim-version;</productnumber>
  12. <address>&vim-url;</address>
  13. </sect1info>
  14. <title>Vim-&vim-version;</title>
  15. <indexterm zone="ch-system-vim">
  16. <primary sortas="a-Vim">Vim</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>Vim 软件包包含强大的文本编辑器。</para>
  21. <segmentedlist>
  22. <segtitle>&buildtime;</segtitle>
  23. <segtitle>&diskspace;</segtitle>
  24. <seglistitem>
  25. <seg>&vim-ch6-sbu;</seg>
  26. <seg>&vim-ch6-du;</seg>
  27. </seglistitem>
  28. </segmentedlist>
  29. <tip>
  30. <title>Vim 的替代品</title>
  31. <para>如果您喜爱其他编辑器 —— 例如 Emacs、Joe、或者
  32. Nano —— 参考 <ulink
  33. url="&blfs-book;postlfs/editors.html"/> 中建议的安装说明。</para>
  34. </tip>
  35. </sect2>
  36. <sect2 role="installation">
  37. <title>安装 Vim</title>
  38. <para>首先,修改 <filename>vimrc</filename> 配置文件的默认位置为
  39. <filename class="directory">/etc</filename>:</para>
  40. <screen><userinput remap="pre">echo '#define SYS_VIMRC_FILE "/etc/vimrc"' &gt;&gt; src/feature.h</userinput></screen>
  41. <!-- <para>Disable a test that fails:</para>
  42. <screen><userinput remap="pre">sed -i '/call/{s/split/xsplit/;s/303/492/}' src/testdir/test_recover.vim</userinput></screen>
  43. -->
  44. <para>准备编译 Vim:</para>
  45. <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
  46. <para>编译该软件包:</para>
  47. <screen><userinput remap="make">make</userinput></screen>
  48. <para>运行以下命令以测试编译结果:</para>
  49. <screen><userinput remap="test">LANG=en_US.UTF-8 make -j1 test &amp;&gt; vim-test.log</userinput></screen>
  50. <!--para>The test suite outputs a lot of binary data to the screen. This can
  51. cause issues with the settings of the current terminal. The problem can be
  52. avoided by redirecting the output to a log file as shown above. A
  53. successful test will result in the words "ALL DONE" in the log file
  54. at completion.</para-->
  55. <para>测试套件会将大量二进制数据输出到屏幕,这可能扰乱当前终端设置。
  56. 为了避免这个问题,像上面的命令一样,将输出重定向到日志文件。
  57. 测试成功完成后,日志文件末尾会包含 <quote>ALL DONE</quote>。</para>
  58. <para>安装该软件包:</para>
  59. <screen><userinput remap="install">make install</userinput></screen>
  60. <!--para>Many users are used to using <command>vi</command> instead of
  61. <command>vim</command>. To allow execution of <command>vim</command>
  62. when users habitually enter <command>vi</command>, create a
  63. symlink for both the binary and the man page in the provided
  64. languages:</para-->
  65. <para>许多用户习惯于使用命令 <command>vi</command>,而不是
  66. <command>vim</command>。为了在用户习惯性地输入
  67. <command>vi</command> 时能够执行 <command>vim</command>,
  68. 为二进制程序和各种语言的 man 页面创建符号链接:</para>
  69. <screen><userinput remap="install">ln -sv vim /usr/bin/vi
  70. for L in /usr/share/man/{,*/}man1/vim.1; do
  71. ln -sv vim.1 $(dirname $L)/vi.1
  72. done</userinput></screen>
  73. <para>默认情况下,Vim 的文档安装在 <filename
  74. class="directory">/usr/share/vim</filename>。下面创建的符号链接允许通过
  75. <filename class="directory">/usr/share/doc/vim-&vim-version;</filename>
  76. 访问符号链接,这个路径与其他软件包的文档位置格式一致:</para>
  77. <screen><userinput remap="install">ln -sv ../&vim-docdir;/doc /usr/share/doc/vim-&vim-version;</userinput></screen>
  78. <!--para>If an X Window System is going to be installed on the LFS
  79. system, it may be necessary to recompile Vim after installing X. Vim
  80. comes with a GUI version of the editor that requires X and some
  81. additional libraries to be installed. For more information on this
  82. process, refer to the Vim documentation and the Vim installation page
  83. in the BLFS book at <ulink
  84. url="&blfs-book;postlfs/vim.html"/>.</para-->
  85. <para>如果在安装 LFS 系统后安装了 X 窗口系统,可能需要在安装 X
  86. 后重新编译 Vim 。
  87. Vim 提供的 GUI 版本编辑器需要 X 和一些额外的软件包才能安装。
  88. 关于这一安装过程的更多信息,参考 Vim 文档和 BLFS 手册中位于
  89. <ulink url="&blfs-book;postlfs/vim.html"/> 的 Vim 安装页面。</para>
  90. </sect2>
  91. <sect2 id="conf-vim" role="configuration">
  92. <title>配置 Vim</title>
  93. <indexterm zone="conf-vim">
  94. <primary sortas="e-/etc/vimrc">/etc/vimrc</primary>
  95. </indexterm>
  96. <!--para>By default, <command>vim</command> runs in vi-incompatible mode.
  97. This may be new to users who have used other editors in the past. The
  98. <quote>nocompatible</quote> setting is included below to highlight the
  99. fact that a new behavior is being used. It also reminds those who would
  100. change to <quote>compatible</quote> mode that it should be the first
  101. setting in the configuration file. This is necessary because it changes
  102. other settings, and overrides must come after this setting. Create a default
  103. <command>vim</command> configuration file by running the following:</para-->
  104. <para>默认情况下,<command>vim</command> 在不兼容 vi 的模式下运行,
  105. 这对于过去使用其他编辑器的用户来说可能显得陌生。
  106. 以下配置包含的 <quote>nocompatible</quote>
  107. 设定是为了强调编辑器使用了新的行为这一事实。
  108. 它也提醒那些想要使用 <quote>compatible</quote> 模式的用户,
  109. 必须在配置文件的一开始改变模式,因为它会修改其他设置,
  110. 因此对这些设置的覆盖必须在设定模式后进行。
  111. 执行以下命令创建默认 <command>vim</command> 配置文件:</para>
  112. <screen><userinput>cat &gt; /etc/vimrc &lt;&lt; "EOF"
  113. <literal>" Begin /etc/vimrc
  114. " Ensure defaults are set before customizing settings, not after
  115. source $VIMRUNTIME/defaults.vim
  116. let skip_defaults_vim=1
  117. set nocompatible
  118. set backspace=2
  119. set mouse=
  120. syntax on
  121. if (&amp;term == "xterm") || (&amp;term == "putty")
  122. set background=dark
  123. endif
  124. " End /etc/vimrc</literal>
  125. EOF</userinput></screen>
  126. <para><parameter>set nocompatible</parameter> 设定使得
  127. <command>vim</command> 以一种更有用的方式(也是默认方式)行动,
  128. 而不是兼容于 vi 的旧模式。如果需要保留旧的 <command>vi</command>
  129. 行为,删除其中的 <quote>no</quote>。
  130. <parameter>set backspace=2</parameter> 设定允许退格越过换行、
  131. 自动缩进和插入模式的起始位置。参数 <parameter>syntax on</parameter>
  132. 启用 vim 符号高亮功能。参数 <parameter>set mouse=</parameter>
  133. 允许在 chroot 中或通过远程连接工作时使用鼠标正确地粘贴文本。
  134. 最后,包含设定 <parameter>set background=dark</parameter> 的
  135. <emphasis>if</emphasis> 语句纠正 <command>vim</command>
  136. 对于某些终端模拟器背景色的猜测,
  137. 这能够提供更适合这些程序黑色背景的配色方案。</para>
  138. <!--
  139. <para>Creating an empty <filename>~/.vimrc</filename> prevents vim from
  140. overriding settings in <filename>/etc/vimrc</filename> by using
  141. <filename>/usr/share/vim/vim80/defaults.vim</filename>.</para>
  142. -->
  143. <para>关于其他可用选项的文档可以通过执行以下命令获得:</para>
  144. <screen role="nodump"><userinput>vim -c ':options'</userinput></screen>
  145. <note>
  146. <!--para>By default, Vim only installs spell files for the English language.
  147. To install spell files for your preferred language, download the
  148. <filename>*.spl</filename> and optionally, the <filename>*.sug</filename>
  149. files for your language and character encoding from <ulink
  150. url="ftp://ftp.vim.org/pub/vim/runtime/spell/"/> and save them to
  151. <filename class='directory'>/usr/share/&vim-docdir;/spell/</filename>.</para>
  152. <para>To use these spell files, some configuration in
  153. <filename>/etc/vimrc</filename> is needed, e.g.:</para-->
  154. <para>默认情况下 Vim 只安装英语拼写检查文件。
  155. 如果希望安装您使用的语言的拼写检查文件,从
  156. <ulink url="ftp://ftp.vim.org/pub/vim/runtime/spell/"/>
  157. 为您的语言和字符编码下载 <filename>*.spl</filename> 和可选的
  158. <filename>*.sug</filename> 文件,并将它们保存到
  159. <filename class='directory'>/usr/share/&vim-docdir;/spell/</filename>。
  160. </para>
  161. <para>为了使用这些拼写检查文件,需要在 <filename>/etc/vimrc</filename>
  162. 中进行配置,例如:</para>
  163. <screen><literal>set spelllang=en,ru
  164. set spell</literal></screen>
  165. <para>关于更多信息,参考以上 URL 位置中合适的 README 文件。</para>
  166. </note>
  167. </sect2>
  168. <sect2 id="contents-vim" role="content">
  169. <title>Vim 的内容</title>
  170. <segmentedlist>
  171. <segtitle>安装的程序</segtitle>
  172. <segtitle>安装的目录</segtitle>
  173. <seglistitem>
  174. <seg> ex (到 vim 的链接), rview (到 vim 的链接), rvim (到 vim 的链接), vi
  175. (到 vim 的链接), view (到 vim 的链接), vim, vimdiff (到 vim 的链接), vimtutor,
  176. 以及 xxd</seg>
  177. <seg>/usr/share/vim</seg>
  178. </seglistitem>
  179. </segmentedlist>
  180. <variablelist>
  181. <bridgehead renderas="sect3">简要描述</bridgehead>
  182. <?dbfo list-presentation="list"?>
  183. <?dbhtml list-presentation="table"?>
  184. <varlistentry id="ex">
  185. <term><command>ex</command></term>
  186. <listitem>
  187. <para>以 ex 模式启动 <command>vim</command></para>
  188. <indexterm zone="ch-system-vim ex">
  189. <primary sortas="b-ex">ex</primary>
  190. </indexterm>
  191. </listitem>
  192. </varlistentry>
  193. <varlistentry id="rview">
  194. <term><command>rview</command></term>
  195. <listitem>
  196. <para>是 <command>view</command> 的受限模式;
  197. 不能启动 shell 命令,且不能挂起 <command>view</command></para>
  198. <indexterm zone="ch-system-vim rview">
  199. <primary sortas="b-rview">rview</primary>
  200. </indexterm>
  201. </listitem>
  202. </varlistentry>
  203. <varlistentry id="rvim">
  204. <term><command>rvim</command></term>
  205. <listitem>
  206. <para>是 <command>vim</command> 的受限模式;
  207. 不能启动 shell 命令,且不能挂起 <command>vim</command></para>
  208. <indexterm zone="ch-system-vim rvim">
  209. <primary sortas="b-rvim">rvim</primary>
  210. </indexterm>
  211. </listitem>
  212. </varlistentry>
  213. <varlistentry id="vi">
  214. <term><command>vi</command></term>
  215. <listitem>
  216. <para>到 <command>vim</command> 的链接</para>
  217. <indexterm zone="ch-system-vim vi">
  218. <primary sortas="b-vi">vi</primary>
  219. </indexterm>
  220. </listitem>
  221. </varlistentry>
  222. <varlistentry id="view">
  223. <term><command>view</command></term>
  224. <listitem>
  225. <para>以只读模式启动 <command>vim</command></para>
  226. <indexterm zone="ch-system-vim view">
  227. <primary sortas="b-view">view</primary>
  228. </indexterm>
  229. </listitem>
  230. </varlistentry>
  231. <varlistentry id="vim">
  232. <term><command>vim</command></term>
  233. <listitem>
  234. <para>文本编辑器</para>
  235. <indexterm zone="ch-system-vim vim">
  236. <primary sortas="b-vim">vim</primary>
  237. </indexterm>
  238. </listitem>
  239. </varlistentry>
  240. <varlistentry id="vimdiff">
  241. <term><command>vimdiff</command></term>
  242. <listitem>
  243. <para>用 <command>vim</command> 编辑两个或三个文件版本,
  244. 并显示差异</para>
  245. <indexterm zone="ch-system-vim vimdiff">
  246. <primary sortas="b-vimdiff">vimdiff</primary>
  247. </indexterm>
  248. </listitem>
  249. </varlistentry>
  250. <varlistentry id="vimtutor">
  251. <term><command>vimtutor</command></term>
  252. <listitem>
  253. <para>教会用户使用
  254. <command>vim</command> 的基本快捷键和命令</para>
  255. <indexterm zone="ch-system-vim vimtutor">
  256. <primary sortas="b-vimtutor">vimtutor</primary>
  257. </indexterm>
  258. </listitem>
  259. </varlistentry>
  260. <varlistentry id="xxd">
  261. <term><command>xxd</command></term>
  262. <listitem>
  263. <para>创建文件的十六进制转储;它也可以从十六进制转储创建文件,
  264. 因此可用于二进制补丁</para>
  265. <indexterm zone="ch-system-vim xxd">
  266. <primary sortas="b-xxd">xxd</primary>
  267. </indexterm>
  268. </listitem>
  269. </varlistentry>
  270. </variablelist>
  271. </sect2>
  272. </sect1>