vim's delete command, is a core command used in every editing session. Delete combos such as
di" will make you happy you chose vim. However, there's a known caveat with the delete command.
the delete command also puts the deleted content into the default register, effectively making the 'delete' command a 'cut' command. This becomes a pain when after cutting one word, you realize you also need to delete some chars with
x or words with
d before pasting the original first word. The other
d's will override the first word.
- Always paste immediately after cutting. This will be OK if you use vim for the occasional editing in a
sshsession. If you use vim as a primary editor, this solution won't suffice.
- Use clipboard managers plugins such as YankRing / YankStack. This helps relief the pain as you can cycle through previous register entries, but it doesn't solve the problem at it's root- the need for different commands for 'cut' and 'delete'. You should use a clipboard manager at any case for yanks. My personal preference is to use OS clipboard managers over plugins.
- Generate mappings to separate 'cut' and 'delete'. The Best solution. The related stackoverflow's question accepted answer suggests a mapping which results in (assuming
leaderis set to
I used this mapping for some time and it does the job quite well. But since 'delete' is much more frequent than 'cut' I switched the mappings around and create this repo which results in (assuming
leader is set to
The mapping will also make
X act as 'delete' rather than 'cut'.