How to write buffer content to stdout?

后端 未结 9 1767
执笔经年
执笔经年 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:37

    Since you use Linux/Unix, you might also be interested in trying out moreutils. It provides a command called vipe, which reads from stdin, lets you edit the text in $EDITOR, and then prints the modified text to stdout.

    So make sure you set your editor to Vim:

    export EDITOR=vim
    

    And then you can try these examples:

    cat /etc/fstab | vipe
    cut -d' ' -f2 /etc/mtab | vipe | less
    

提交回复
热议问题