Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim save highlight info screen to file

Tags:

vim

Is there a way in Vim to save the window that comes up if you type :highlight? I'm working on a color scheme and it would be helpful to be able to have a copy of it open in a real window (so I can search, or delete lines once I've taken care of them in my color scheme). I've already tried :h :highlight, which doesn't turn up anything useful, but surely there must be a way. Thanks!

like image 565
Michael M. Avatar asked Dec 26 '22 05:12

Michael M.


2 Answers

You can use redir to redirect the output of highlight to a file.

In vim you run

:redir > file
:highlight
:redir END

file should now contain the output of highlight.

Update: One way to highlight the xxx in the highlight file is to run the function below

function! HiFile()
    let i = 1
    while i <= line("$")
        if strlen(getline(i)) > 0 && len(split(getline(i))) > 2
            let w = split(getline(i))[0]
            exe "syn match " . w . " /\\(" . w . "\\s\\+\\)\\@<=xxx/"
        endif
        let i += 1
    endwhile
endfunction

The function uses syn match to match the highlight group with the xxx after it.

You can place the function in your vimrc and then to run it type :call HiFile() while in the highlight file.

like image 158
FDinoff Avatar answered Dec 28 '22 18:12

FDinoff


There's a menu command Syntax > Highlight Test that creates a buffer with all highlight groups. Alternatively, you can trigger it via

:runtime syntax/hitest.vim
like image 45
Ingo Karkat Avatar answered Dec 28 '22 18:12

Ingo Karkat