Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outputting shell-command-edited buffer into a new buffer in Vim? E499: Empty file name for '%' or '#', only works with ":p:h"

Tags:

vim

This thread here discuss about piping output of shell command into a new buffer in vim but it does not discuss it by using the current buffer like

 %new | r !%gcut -d '"' -f2,4,6,8,10

where the percentage sign % tries to use the current buffer, unfortunately resulting to

E499: Empty file name for '%' or '#', only works with ":p:h"

so

How can I pipe the shell-command-edited buffer into a new buffer in Vim?

like image 632
hhh Avatar asked Oct 15 '25 17:10

hhh


1 Answers

:new | r !gcut -d '"' -f2,4,6,8,10 #

# is a placeholder for "the previous file".

If you have spaces in the filename, then use quotes

:new | r !gcut -d '"' -f2,4,6,8,10 "#"
like image 150
romainl Avatar answered Oct 18 '25 13:10

romainl