Monday, May 21, 2012

Re: Using vim to syntax highlight stdin

Ben Fritz <fritzophrenic@gmail.com> wrote:

> On Sunday, May 20, 2012 6:36:02 PM UTC-5, Scott wrote:
>> I know I'm trying to abuse Vim in ways it's not supposed to be used, but I'm just wondering if this is possible ...
>>
>> Is there any way to configure vim to syntax highlight stdin & NOT paginate?
>>
>> eg. ./myprog | vim --insert-magic-here
>>
>> The less.sh script does all the syntax highlighting I want, but it paginates it's output which I do not want.
>>
>
> You will probably need to set the filetype manually, but Vim can easily handle stuff from stdin. E.g.
>
> ./myprog | vim -c "setl filetype=myfiletype" -

Vim can automatically detect file files from stdin for some file types
by looking at the content. This is done in $VIMRUNTIME/scripts.vim.

It should work for xml files for example:

$ vim - < foo.xml

-- Dominique

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: