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? You can use the :! command to pipe the contents of the current buffer to an 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: :range! 10.9 :w_c

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind