完整的 Vim 配置教程请参阅我的博文:Vim 开发环境配置,下面是这篇博文的补充内容。


正如 indentLine 的 GitHub 主页 上说的那样子,要自定义对齐字符,首先要下载安装 FontForge,Mac 下在安装之前需要首先安装 XQuartz,这两个软件都安装完成之后,按照官方所说的步骤操作如下:(将 Vim 原来使用的那个字体卸载掉,譬如我原来用的是 Monaco for Powerline,然后在网上重新把这个字体下载下来,经过下列操作后再重新安装新生成的字体)

  1. Download and install FontForge.
  2. Locate and open your terminal/gVim font.
  3. Open the font in FontForge, choose Goto from the View menu and select Private Use Area from the drop down box.
  4. In the private use area, locate a blank spot for the glyph. Make a note of the code, e.g. U+E0A3.
  5. Double-click the selected code point to open the font drawing tool.
  6. From the File menu, select Import… and locate the indentLine-dotted-guide.eps file.
  7. Once imported, choose File -> Generate Fonts and choose a location and file type for the new font.

在以上步骤中,可能会出现警告让你在 FontForge 的菜单栏中依次点击 Element -> Font Info... -> General 来修改 Em Size 的值为 1000,按它说的做。

在以上步骤中,生成字体的时候,选择以下字体类型:

生成的字体类型

找到新生成的字体并将其安装到系统中,修改 .vimrc 文件,将字体设置成刚才安装的新字体。用 FontForge 打开新生成的字体,找到你在步骤 6 中 import 的符号,右击,然后依次选择 Glyph Info... -> Unicode,复制下面红色方框的内容:

复制该内容

在 .vimrc 文件中,删除原来语句 let g:indentLine_char = '' 中单引号的内容(如果没有这条语句的话请新建它),将以上复制好的红色方框中的内容粘贴到单引号内,保存,重启 Vim,其缩进符号就可以得到下面这种使用 Patched font 的效果:

From https://github.com/Yggdroot/indentLine