vim.xml 13 KB

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