I'm using neovim with vim-plug.

I do some webapp testing where I want to see the raw HTML/JS/PHP/etc of a page. This can be done with something like curl example.com > tmp.html; nvim tmp.html and nvim would load plugins and commands to be used on HTML files. However, I'd rather not save & open files like that for every page.

What I usually do is use python-requests for testing. The python script would GET/POST a page and output the HTML and some extra python output. For example:



import requests


p = requests.get("http://example.com")



$ ./get.py | nvim -

(It can be as simple as printing some extra text or extra processing with grep. Non-HTML output is expected.)

When there's non-HTML output, I don't get HTML syntax-highlighting & HTML plugins aren't loaded. These should all be formatted in a temporary buffer for rapid testing.

I can make an augroup to run some commands but I'm not sure plugins would be loaded. Some plugins may be loaded but certain filetype-specific functions of the plugins don't work (eg Coc's coc-prettier).

How can I "cast" the filetype to HTML/JS/PHP/etc and have nvim load everything that should be loaded when an HTML file is opened?

1 Answer 1


One way to do it is just force the filetype:

vim <(script | ...) -c 'set filetype=html'

Or inside vim

:set filetype=javascript

(For example)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.