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?

3
  • What terminal do you use? I can use the scrollwheel in less (Ubuntu 10.10 / Gnome Terminal).
    – romainl
    Jan 8, 2012 at 12:53
  • iTerm 2 on Lion Jan 10, 2012 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, 2012 at 10:37

1 Answer 1

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.

2
  • Which part of this passes the non-regular file as an argument to vim? Jan 8, 2012 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. Jan 9, 2012 at 13:20

You must log in to answer this question.

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