Re:Vim Creep
by sophacles on Thursday July 12, 2012 @04:59PM
(#4236780)
For completeness - same task in vim:
start recording a macro:
qa
Then enter this sequence of keystrokes[1]:
0veyO// Run the ^R" command<esc>j0f.C()<cr>end<cr><esc>
Then exit macro recording with:
q
Then enter the command:
:g/.rb$/ norm @a
to run the macro on every line ending with .rb (allowing comments in the input, just because (of course it would be nice to make that regex in :g look for "lines that start with comments" and ignore them explicitly)).
If I counted right, thats 57 keystrokes, and I might have been slightly inefficient in my usage, of course, if that one keystroke is part of a command my fingers just do, there is no effective difference :)
[1] I know it was exactly that sequence because I just pasted the macro buffer, which of course can then be edited, saved back to the buffer and run in edited form.
Re:Vim Creep
by weaksauce on Thursday July 12, 2012 @05:19PM
(#4236888)
I'm an intermediate user of vim but the filtering the macros to only run on those lines is a great tip! I did it a bit different but we had a similar idea.
start recording a macro:
qa
Then enter this sequence of keystrokes[1]: 0veyO// Run the ^R" command<esc>j0f.C()<cr>end<cr><esc>
Then exit macro recording with: q
Then enter the command: :g/.rb$/ norm @a
to run the macro on every line ending with .rb (allowing comments in the input, just because (of course it would be nice to make that regex in :g look for "lines that start with comments" and ignore them explicitly)).
If I counted right, thats 57 keystrokes, and I might have been slightly inefficient in my usage, of course, if that one keystroke is part of a command my fingers just do, there is no effective difference :)
[1] I know it was exactly that sequence because I just pasted the macro buffer, which of course can then be edited, saved back to the buffer and run in edited form.