Is it possible to display page feed symbols differently in 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.

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

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).


I don't think you can. There is a non-text highlight group which could help. Another way (a bit ugly) would be to write some autocommand to expand ^L to ---- new page ---- and vice versa when on InsertLeave, BufRead and BufSave.

Anyway, the answer of your question is no, if you just want to change the display, and probably yes with a nasty plugin.

Tags:

Vim

Folding