Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I pipe the contents of the current buffer to an external command and replace the contents of the buffer with the output from the command?

0
Posted

How do I pipe the contents of the current buffer to an external command and replace the contents of the buffer with the output from the command?

0

:! command to pipe the contents of the current buffer to a external command and replace the contents of the buffer with the output from the command. For example, to sort the contents of the current buffer, using the Unix sort command, you can use the following command: :%!sort To sort only lines 10-20, you can use the following command :10,20!sort Also, if you want to pipe a buffer to an external command but not put the results back in the buffer, you can use :w !sort The above command will pipe the entire buffer to the sort command. Note that the space between the ‘w’ and the ‘!’ is critical. To pipe only a range of lines, you can use :10,20w !sort The above command will pipe the lines 10-20 to the sort command. For more information, read :help :range! :help 10.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123