I don't know if its a retarded problem but it's a funny dilemma. When I want to delete text that I want to place somewhere else, but that place has other bunch of text that I don't want, I would delete that text, but in the process I copy a new clipboard so the previously deleted text disappear.
Any suggestions to solve this?
Deleting a single line in Vim editor: First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.
To delete a word, position the cursor at the beginning of the word and type dw . The word and the space it occupied are removed. To delete part of a word, position the cursor on the word to the right of the part to be saved. Type dw to delete the rest of the word.
Delete a Range of LinesUse Esc to switch to normal mode in Vim. Once you press Enter, the specified lines are removed, as in the image below.
Once the text is highlighted, press the d key to delete the text. If you deleted too much or not enough, press u to undo and start again. Move your cursor to the new location and press p to paste the text.
A few possible solutions:
Delete the undesired text first :)
or
When deleting the desired text store it in a register other than the default register e.g. to delete the desired text to the end of the current line and store it in register b:
"bd$
Then delete your undesired text.
Then paste the contents of register b:
"bp
or
Delete the undesired text to the black hole register as suggested in the answer linked to by Yarek T using:
"_d
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