How to write buffer content to stdout?

后端 未结 9 1717
执笔经年
执笔经年 2020-12-09 01:54

Is there any chance to write the content of the current vim buffer to stdout?

I\'d like to use vim to edit content that was passed via stdin - without the need of a

9条回答
  •  既然无缘
    2020-12-09 02:22

    vim can be used in pipes as full-featured filter with explicit names for stdin and stdout as in following example:

    echo xxx                                             |
    vim                                                  \
      -esnN -i NONE                                      \
       +'1 s /x/y/g | 1 s /^/Hallo / | x! /dev/stdout'   \
       /dev/stdin                                        |
    cat -n
    

    Abbreviating /dev/stdin with - won't work, even not with -v flag.

提交回复
热议问题