Vim: apply macro to entire file

Input:

username1
username2
username3

Target Output:

[email protected]
[email protected]
[email protected]

Vim Commands:

gg0                # move cursor to first char in file
[email protected]   # record actions into macro q, then undo
:%norm! @q              # apply macro q to entire file
:wq                     # save and exit

 

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s