 |
|
| Computers Forum Index » Computer - Editors » Generating Lines of Repetitive Code Rapidly... |
|
Page 1 of 1 |
|
| Author |
Message |
| zzapper... |
Posted: Sat Sep 12, 2009 6:50 pm |
|
|
|
Guest
|
A very common editing problem when writing repetitive lines of code.
list($jan,$jan_color)=fn_display_month($record['jan']);
list($feb,$jan_color)=fn_display_month($record['jan']);
list($mar,$jan_color)=fn_display_month($record['jan']);
..... etc etc
list($nov,$jan_color)=fn_display_month($record['jan']);
list($dec,$jan_color)=fn_display_month($record['jan']);
The first line (jan) has been hand written and then the other 11
generated with yy11p
Then the first mention of the month has been hand-edited, now you want
to make the
month the same throughout the line
list($jan,$jan_color)=fn_display_month($record['jan']);
list($feb,$feb_color)=fn_display_month($record['feb']);
list($mar,$mar_color)=fn_display_month($record['mar']);
.....
list($nov,$nov_color)=fn_display_month($record['nov']);
list($dec,$dec_color)=fn_display_month($record['dec']);
Do this with a recording:- with contents
0f$l"ayiw:s/jan/\= at (no spam) a/gj
explanation
Start recording at (no spam) q
0f$ find first dollar
store month into register a
substitute jan with contents of register a
descend a line
q to end recording
11 at (no spam) q to repeat on all lines
Any other/better ways?
zzapper
http://zzapper.co.uk/vim-tips-blog Vim Tips Blog |
|
|
| Back to top |
|
|
|
| Mikolaj Machowski... |
Posted: Sat Sep 12, 2009 7:18 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Thu Dec 10, 2009 4:36 pm
|
|