1

I want to display a file in Neovim with ansi terminal escape codes interpreted.

I created a file which contains ansi escape codes (only colors for now, we can think about others as a bonus):

echo '\e[31mred\e[m other \e[32mgreen\e[m end' > file

Now if I open this file in neovim I can see and edit the escape chars but the colors are not displayed: nvim file

nvim plain

I know about the AnsiEsc plugin and it can do the job pretty good: nvim file +AnsiEsc

ansiesc

but it misses the point about my color scheme and it is an external plugin. Also it uses syntax groups and these are limited in number and have to be defined manually by the maintainer. I am not sure if it even can interpret other stuff besides color escape codes.

Obviously the internal :terminal should solve these restrictions, but if I use :terminal cat file to view the file it adds extra text at the end and also adds extra empty lines to fill the window: nvim '+term cat file'

nvim terminal

The :terminal of plain vim does a better job in this regard: vim +'term ++curwin cat file'

vim terminal

It doesn't print extra text at the end of the command output (no message and no empty lines). But then again I want to use neovim :(

Question: Can something as close as possible as the vim version be achieved with neovim's :terminal?

EDIT: I since came half a step further: If I use nvim '+term tail -f -n +1 file' the process never terminates (tail -f) and hence the indicater that neovim normally prints is gone. Id did not see a problem with the running tail process in my use case but it would obviously be nicer if the process was finished. That's why it is only half a step. The additional lines at the end are still there:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.