Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
What terminal do you use? I can use the scrollwheel in less (Ubuntu 10.10 / Gnome Terminal). – romainl Jan 8 '12 at 12:53
    
iTerm 2 on Lion – AlcubierreDrive Jan 10 '12 at 10:14
    
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 Jan 10 '12 at 10:37
up vote 0 down vote accepted
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.

share|improve this answer
    
Which part of this passes the non-regular file as an argument to vim? – Ignacio Vazquez-Abrams Jan 8 '12 at 2:59
    
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. – MikeSep Jan 9 '12 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .