Usually, vim will get the highlighting right from the file extension, but this obviously doesn't work when I'm displaying content read from standard input.

cat File.hs | some | processing | pipeline | view -

I can obtain the proper highlighting with

:set syntax=haskell

but that's awkward to do multiple times. How do I select the highlighting right at command-line invocation?

cat File.hs | vim -R {???syntax=haskell} -

1 Answer 1


You can use +command to execute command after the "file" is loaded:

cat File.hs | some | processing | pipeline | vim -R +'setf haskell' -
  • Great, works. What exactly is setf? Mar 19, 2016 at 16:40
  • 2
    See :help :setf.
    – romainl
    Mar 19, 2016 at 17:56

Your Answer

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

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