I've got a program that looks something like this:
#Begin code
$sth->bind_param(1, 'blahblah');
$sth->bind_param(2, $somevar);
#End Code
I want to change it to this:
#Begin code
$sth->bind_param(1, $somevar);
$sth->bind_param(2, 'blahblah');
#End Code
Here's how I would do it in VI:
Go to the 1. Type 'I' (Insert Mode), change it to 2. Go to the 2, change it to 1. Type 'ESC'
Do to the first line. Press DD (Delete). Arrow down. Press P (Paste). Arrow up, and DD the blank line inserted. Arrow down, press I (Insert), backspace, hit return, then fix the indenting on the next line.
I'm 100% convinced this is a silly, inefficient way to type. Yes, it beats the heck out of some GUI Windows-like text editor, but still, it should be faster. I just don't know enought about VI (or vim) yet.
Ideas are welcome.
Do it in Perl (Score:2)
Or thereabouts. Seems to me that you don't need to switch the parms, but rather switch their bind numbers.
It's a quick throwaway tool, but that's
--
xoa
Re:Do it in Perl (Score:1)
perl -0777 pi.bak -e 's/\(1, ([^\)]+)\)(.*?)\(2, ([^\)]+)\)/(1, $3)$2(2, $1)/gs' file.plDisclaimer: Not tested extensively.
here's some small improvements (Score:2)
The "r" is useful to change one character ("R" will overwrite a bunch of chars, it's like insert mode but overwrites).
The "ddp" switches the current line with the next. It is a variant on the very useful (especiall
vi is like perl (Score:2)
I found that my initial use of vi was adequate, but that every 6 months or a year I would read through the vi manual and pick a few more useful idioms and add them to the set that I knew well enough to use without thinking. After a few years of this, my vi repertoire was large enough that most of the new idioms I tried to learn were not useful o
vim: C-A C-X (Score:2)
<C-A>ddpk<C-X>
Re:vim: C-A C-X (Score:1)
Also, to make it even easier, a temporary binding can be created using map.
Of course, a better (preferably unused) key may be used in place of
I just chose that as it is rarely used, I think.Finally, something I know... (Score:1)
Buck