I have a file with data that goes like this.
Engine1 Temp:10 Humidity:23 Engine1 Temp:13 Humidity:21 Engine2 Temp:10 Humidity:23
This pattern repeats throughout the file. I want to do the following in a single vim command.
- Search for
- Copy the line that has the pattern
- Copy the next 2 lines (which has the data related to it)
- Output the results to a new file
This command needs to do this for the whole file wherever this pattern appears.
let @c=''|:g/engine1/1,3y Cthen in the new file
"cPwill paste the match. regular expression deletion will help. Depending on what you mean by file
:h :redirmay assist