tags:

views:

96

answers:

3

I want a way to pass some literal text to Vim. I've seen that it can read from stdin with the "-" argument, so you can pipe things to it, e.g. the output of other commands.

But is there a way to pass any text into it like

vim - "Here's some random text"

and open Vim with that string in the buffer?

It complains if I try this command...

+5  A: 
echo string | vim -
Mehrdad Afshari
+ in `bash` one can do a `vim - <<<$string`
Michael Krelin - hacker
A: 
cat some_file | vim -

This is the correct way to pipe into vim.

Shin
Except that the OP was asking how to pipe a literal string in, not the contents of a file.
EBGreen
+13  A: 
$ echo "Here's some random text" | vim -
Eimantas