Two of my favorite Vim features are the ability to apply standard operators to strings matching a regular expression, and the ability to filter the selection or range of strings through an external command. But can these two ideas be combined?
For example, I have a text file that I use as a laboratory notebook, with notes from different dates, separated by a dash line. I can do something like delete all dashes with something like :% g/^-/d. But let me say that I wanted to resize all text lines without touching these dashed lines.
For one paragraph, it will be something like {!}fmt. But how can this be applied to all paragraphs without a stroke? When I try, that seems logical, and just connect the two together with it :% v/^-/!fmt, it doesn't work. (Actually, it looks like he broke Vim ...)
Is there a way to combine these two ideas and only pass the strings (not) matching the pattern to an external command, for example fmt?
source
share