vim-find-files icon indicating copy to clipboard operation
vim-find-files copied to clipboard

Strip off ANSI Escapes from g:find_files_findprg command output

Open phongvcao opened this issue 4 years ago • 1 comments

Output from g:find_files_findprg command may contain AnsiEsc sequence (e.g.^[[0m^[[32m./output/dir^[[0m). This pull request makes vim-find-files able to open files/directories in the "File List" buffer with AnsiEsc sequence in it (by stripping off the ansi escape sequence before following the link to the file).

This allows vim-find-files to have output being colored inside Vim using AnsiEsc plugin by adding the following setting to .vimrc:

function! SetHighlightFindFiles()
    if &filetype ==# 'findfiles'
        AnsiEsc
    endif
endfunction

augroup my_find_files_customization
    autocmd! FileType findfiles :call SetHighlightFindFiles()
augroup END " my_find_files_customization

And here is the result (with "File List" buffer with syntax highlight using AnsiEsc):

Screenshot at Jul 26 21-43-13

phongvcao avatar Jul 27 '20 04:07 phongvcao

The current code in the master branch uses "gf" to navigate to the filenames in the "File List" window, which would be impossible if the output "File List" window contains ANSI Escape sequence like this:

Screenshot at Jul 26 21-46-23

(this screenshot is what things look like without AnsiEsc and the code in this pull request)

phongvcao avatar Jul 27 '20 04:07 phongvcao