On 2011-04-22, Tony Mechelynck wrote: > On 22/04/11 07:36, Adam Monsen wrote: > >You've this mistake before, right? > > > > cat /tmp/foo.txt | vim > > > >when you meant to do > > > > cat /tmp/foo.txt | vim - > > > >Somewhere early in my Vim learning I figured out the latter, so I > >usually don't repeat the mistake. > > > >But why *is* that even a mistake? What is the purpose/origin/history > >of the first example, the vim "sans-dash" behavior? > > > >Seems like the "vim -" behavior (read text from stdin) would make > >for a much more useful default. > > > > Vim needs to read your keyboard commands from somewhere; so normally it > reads them from stdin, or if in GUI mode and there is no stdin, then > from the GUI (X11, Windows, etc.) keyboard dedvice. It's not like so > many batch command-line utilities which take no interactive input but > only command-line arguments, and thus can default to stdin if no > specific input file is given. > > When Vim is not started with an editfile specified, it opens an empty > [NoName] file: it doesn't take your keyboard input as raw file data to > be edited later (maybe after you signal an end-of-file by hitting Ctrl-Z > on Windows or Ctrl-D on Unix). > > In the special case when you specify stdin as input, Vim reads it all as > an input file, marks it as modified except if readonly, and then starts > reading your keypresses from somewhere, maybe stderr though it is > somewhat strange to use the "error output device" for input.
Couldn't vim just as easily use isatty(0) instead of "-" to determine whether data is coming from stdin? It has /dev/tty for keyboard input. I think that's what less does. Regards, Gary -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php