How to write buffer content to stdout?

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

    You can use the ex-mode (p)rint command to print any set of lines you want to stdout.

    print all lines:

    :1,$p
    

    Also prints all lines (% is a shorthand for the range 1,$)

    :%p
    

    print lines 4-10:

    :4,10p
    

    print next line containing FOO

    /FOO/ p
    

    print all lines containing FOO

    g/FOO/ p
    

提交回复
热议问题