Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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