是否可以在 Vim 中以不同的方式显示页面提要符号? [英] Is it possible to display page feed symbols differently in Vim?

查看:22
本文介绍了是否可以在 Vim 中以不同的方式显示页面提要符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vim 的一个好处是可以插入一个换页符(Ctrl-L 在插入模式下),它委托打印机开始打印在新页面上关注.它在文本中显示为 ^L.

One of the nice things about Vim is that one can insert a page feed symbol (Ctrl-L in Insert mode), which delegates the printer to start printing the following on a new page. It shows as ^L in text.

是否可以使这个符号显示为其他东西,例如

Is it possible to make this symbol show as something else, for example as

----------------- new page here -----------------  

所以它在滚动文本页面时更明显?

so it is somewhat more visible while scrolling through pages of text?

也就是说,无需从源代码重建 Vim.

推荐答案

如果在编辑这些文件时没有广泛使用折叠包含换页符号,您可以使用单行折叠来标记他们出去.

If you do not use folding extensively when editing those files containing page feed symbols, you can use one-line folds to mark them out.

使用 foldexpr 选项,可以增加折叠级别包含页面提要符号的行.(在此,为了评估 foldexpr 的效率,我假设页面提要符号始终是其行中的第一个字符.)为了实现屏幕宽分隔符的所需效果,可以进行这些折叠可自动关闭.

Using the foldexpr option, it is possible to increase the fold level of the lines that contain page feed symbol. (Herein, for the sake of efficiency of evaluating foldexpr, I assume that page feed symbols are always the first characters on their lines.) To achieve the desired effect of a screen-wide separator, these folds can be made auto-closable.

以下函数根据思路配置折叠如上所述.调用它(手动或通过自动命令)在当前缓冲区中启用页面提要符号折叠.

The following function configures folding according to the idea described above. Call it (manually or by means of an autocommand) to enable page feed symbol folding in the current buffer.

function! FoldPageFeed()
    setl foldmethod=expr
    setl foldexpr=getline(v:lnum)[0]==\"\\<c-l>\"
    setl foldminlines=0
    setl foldtext='---\ new\ page\ '
    setl foldlevel=0
    set foldclose=all
endfunction

结果分隔符显示为文本 --- new page 后跟窗口右侧的连续填充字符字符串(参见 :help fillchars,在 fold: 项下).

Resulting separators appear as the text --- new page followed by a continuing string of filling characters to the right of the window (see :help fillchars, under the fold: item).

这篇关于是否可以在 Vim 中以不同的方式显示页面提要符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆