I had to take something like this:
$output.="blah blah blah blah blah";and turn it into something like this:
$output.="blah blah blah blah blah\n";Unfortunately for me, there was a TON of lines like this.
After attending a great talk at nycpython by Justin Lilly on editor efficiency, I decided to try out a 'vim macro' for the first time.
Here's how I solved this problem:
- type 'qq' to start recording my macro
- type '$' to get to the end of the line
- hit 'h' twice to move the cursor left twice
- hit 'i' to go into insert mode
- type '\n' to put in my line break
- hit the esc key to get out of insert mode
- hit 'j' to move down to the next line
- hit 'q' to stop recording the macro
- type '20@q' to execute the macro 20 times
qq commands q..and then to execute it multiple times:
x@q...where 'x' is the number of times you want to execute it.
I'm sure that there are many ways to do this, being that vim is such a powerful editing tool.
Anyways, the macro is definitely a tool I see myself using in the future, as it cut down the monotony and time needed to accomplish this annoying task.
Happy coding,
Sean
No comments:
Post a Comment