When I opened a vim editor on terminal, I copied the following text to clipboard from another source
int thisVal = findMin(m);
// System.out.println(val);
m.add(val);
But it becomes
int thisVal = findMin(m);
// System.out.println(val);
// m.add(val);
Why is this case and how to paste correctly with the formatting? Thank you.
To put the yanked or deleted text, move the cursor to the desired location and press p to put (paste) the text after the cursor or P to put (paste) before the cursor.
In Vi/Vim, the paste operation is called a put operation. The only way to paste in Vi/Vim is to place the cursor at the desired location and use “P” to paste text before or after the cursor.
vim Inserting text Disable auto-indent to paste code Just press F3 in insert mode, and paste. Press F3 again to exit from the paste mode.
:set paste
should cause indenting to work correctly. As uku points out, you can read more information on paste mode using
:h paste
you can turn off paste mode with
:set nopaste
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With