This answer states that :w !tee writes current buffer to stdout. Why and how does it work? Can I write :x !tee or :w !cat? What's exclamation mark meaning in this case? (I assume it's not forcing operation.) Does it work only if tee command exists (not on Windows)?
Asked
Active
Viewed 120 times
1
Community
- 1
- 1
George Sovetov
- 4,474
- 5
- 31
- 55
1 Answers
3
! tells vim that it's a shell command and not a filename. So :w !tee or :w !cat gives the vim buffer to those commands as input. They in turn send the buffer content to stdout.
Try :w !wc -l, this will give you number of lines in your buffer printed on stdout.
You can also read output from a command into vim buffer. You can use read command with a shell command. For example, :read !date executes the date command on shell and sends the output back to vim buffer.
ronakg
- 3,771
- 20
- 39
-
Thanks, it's getting clearer for me! Using your answer, I managed to find [documentation page](http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window). – George Sovetov Apr 12 '16 at 21:43