vi editor - interchange two lines

Hi,

   I have a quick question regarding vi editor.Is it possible to interchange two lines in vi editor without using the possibilites of cut-paste,copy paste etc?

Your help is appreciated!

Regards
Dileep

you need to 'map' certain key-stroke to do this

In vi, go into the command mode by keeping the following

:map , ddp

If you position your cursor in that line, by typing the "," (comma) key it will delete the current line and paste it below the current cursor. Basically it swaps the two lines.

Thanks for your reply.But sorry i didn't get you properly.Can you put the logic in steps if you don't mind - for swapping two lines in vi editor.

Regards
Dileep Pattayath

You can just type 'ddp'. dd = delete line, p = paste below. Chihung's method just defines a macro so you can do it with one keypress... which part do you need explaining?

Now,I got it.I intrepret the statement you gave in a different way,but finally caught what you had suggested.It's seems great.

Thank you so much!

Regards
Dileep Pattayath