Macro recording and playback in vi

Had to correct around 2700+ lines of text in linux with the following changes :

  1. Search for <ctrl>M character inside the file
  2. Remove the <ctrl>M
  3. Join the next line to this line and complete the line.

Can’t do with single command and repeat with the “.” to replay the operation. Had learnt the macro recording of actions and playback sometime back in vi editor and wasn’t able to recollect the steps, refreshed it again today. Thought will blog it for others and for me to recollect when required later!.

  1. character q followed by one of a to z key to remember the recording
  2. character / followed by <ctrl>v and M
  3. character x to remove the <ctrl>M character
  4. character J to bring the next line and join to this line
  5. character q to stop recording
  6. type number 2800 and character @ followed by the key that held the recording

All replaced!. Save and come out..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s