vim -R /dev/random

1

I am on the verge of doing alias less='vim -R' for the convenience of being able to scroll with my multitouchpad.

However, I like that less -f can view even files like /dev/random that are not regular files.

How do I hack vim -R so it can read-only non-regular files too?

AlcubierreDrive

Posted 2012-01-08T01:54:56.257

Reputation: 357

What terminal do you use? I can use the scrollwheel in less (Ubuntu 10.10 / Gnome Terminal). – romainl – 2012-01-08T12:53:13.800

iTerm 2 on Lion – AlcubierreDrive – 2012-01-10T10:14:18.980

On the Mac, I have a SIMBL plugin called MouseTerm that allows to use the scrollwheel in less or vim in Terminal.app. iTerm2 is supposed to support the mouse but I see no mention of the scrollwheel. It looks like an iTerm2 limitation. – romainl – 2012-01-10T10:37:16.277

Answers

0

head -c 10 /dev/random | vim -b '+set bt=nowrite' -
  • -b binary mode
  • +set bt=nowrite no warning when quit without save
  • - read stdin

To get 100 bytes, you can change 10 to 100.

kev

Posted 2012-01-08T01:54:56.257

Reputation: 9 972

Which part of this passes the non-regular file as an argument to vim? – Ignacio Vazquez-Abrams – 2012-01-08T02:59:56.073

The - at the end makes vim accept input from stdin. I often do things like grep pattern file.txt | vim -R - so that I can then use vim's search on my grep results. – Mike Seplowitz – 2012-01-09T13:20:51.833