Say you have some text like this:## countries, primaryUnited States,Washington,North AmericaCanada,Ottawa,North AmericaAustralia,Canberra,Oceania## countries, secondaryFrance,Paris,EuropeJapan,Tokyo,AsiaUnited Kingdom,London,EuropeAnd you want to filter only the non-comment lines through an external program, say column -ts,, to align the comma-separated fields. In other words, the expected output is:## countries, primaryUnited States   Washington  North AmericaCanada          Ottawa      North AmericaAustralia       Canberra    Oceania## countries, secondaryFrance          Paris       EuropeJapan           Tokyo       AsiaUnited Kingdom  London      EuropeIs it possible to do this in vim with a single command?I thought maybe combining :g with :range! would work, but it doesn't:g!/^\s*#/!column -ts,The above just runs :!column -ts, once for each line that matched the :g command. In other words, it doesn't actually filter anything, it just runs a system command with stdin connected to the terminal, once for each matching line.So, the general question is, how can we filter discontinuous line sets through an external program, passing all the lines as one block to the stdin of the external program, and returning the output lines back to their corresponding line numbers in the buffer?
How to filter discontinuous line sets through an external program (Is it possible to combine :g global command with :range! external program filter)?
command line;external command;range