How do I exchange (swap) two characters or words or lines?

You can exchange two characters with the “xp” command sequence. The ‘x’ will delete the character under the cursor and ‘p’ will paste the just deleted character after the character under the cursor. This will result in exchanging the two characters. You can exchange two words with the “deep” command sequence (start with the cursor in the blank space before the first word). You can exchange two lines with the “ddp” command sequence. The ‘dd’ will delete the current line and ‘p’ will paste the just deleted line after the current line. This will result in exchanging the two lines. All of the above operations will change the “ unnamed register. You can use the “:m +” ex command to exchange two lines without changing the unnamed register.

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind