How to write buffer content to stdout?

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

    Try something like:

    { FROMCMD | vim - 8>&1 >&9 | tac | tac | TOCMD; } 9>&1
    

    and use ':w !cat >&8' when you are finished editing

    'tac | tac' ensures that TOCMD doesn't receive any data until you quite vim, this is only useful if TOCMD writes to the terminal so that it doesn't make a mess while vim is still running.

    Notice that running 'less' as your TOCMD (or any other program that do some terminal manipulation) is not going to work as expected because even if you delay the data, the processes still start "at the same time" and may access the terminal at the same time.

提交回复
热议问题