Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a way to kill something without putting it in the kill ring? It's probably my biggest pet peeve about emacs that there's no way to kill text without emacs assuming that you want it somewhere else.


M-x delete-region by default (although you can bind it to anything).

I use emacs every day, and don't think I've ever used it though. Just put the stuff you want to delete in the kill ring.

Why don't you want stuff in the kill ring? It takes some getting used to, but I've found it's generally a good thing. You can always yank back previous items in the ring with M-y too, so it isn't like your OS clipboard where 'cutting' something else means you lose access to the previous item on the clipboard.


Because sometimes I want to cut A, delete B, paste A where B used to be, and it's irritating to have to have that extra M-y in there.

Perhaps I should instead write a new command to kill a region, but then swap the last two things in the kill ring. That's actually a good idea...


In addition to the other two solutions, you can also use registers: http://www.emacswiki.org/emacs/Registers


I just kill A, yank A, then kill B...


kill A, select B, yank.


Also see delete-selection-mode. If you have:

    (delete-selection-mode 1)
    (transient-mark-mode 1) ; enabled by default in emacs 23+
you can mark a region and press delete or backspace (or start typing replacement text) to delete the region without affecting the kill ring.


M-x delete-region


For me, M-d, (which I remapped from C-d?) does not put the text into the ring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: