4 ms·
> Do you mean something like this? :r! lshw | grep network -A2 | grep : | cut -d: -f2- | paste - - Not exactly. More like: - Open vim with the output of
by gwn7 8y ago
> Do you mean something like this?
:r! lshw | grep network -A2 | grep : | cut -d: -f2- | paste - -
Not exactly. More like:
- Open vim with the output of `lshw` as content:
lshw | vim -
- Examine the raw data
- Send the whole content of the buffer as standard input to the given command and rewrite the buffer with the data read from the standard output of it:
:%! grep network -A2
- Examine the returned dataset. Iterate:
:%! grep :
- Examine & iterate:
:%! cut -d: -f2-
- Examine & iterate:
:%! paste - -
This way, you can examine the output of each step of the pipeline individually, so you can construct your command incrementally. And it is up to you to decide at which point a command will be run instead of it being run automatically following every keypress.
Since the dataset returned by the last command will be visible in the current buffer, you will be able to examine & play with it full screen. You will be able to clean or transform some parts manually (this is frequently needed in data science).
You can always return to the previous/next dataset by pressing u/Ctrl+R (for undo and redo), and examine your command history by pressing ":" and then Ctrl+P/Ctrl+N. (Or you can open the command history quickfix menu by pressing "q:" to view/copy the last several commands at once.)
And since you are in a full blown text editor, you can take advantage of other helpful features such as folding, saving the current dataset to a temporary file, etc.
If you are comfortable with more than a few UNIX filters, VIM can be a very convenient and fun tool to play with data.