18 votes
Accepted

How to select and delete a column of text in emacs?

C-w kills the text between point and mark; it’s the normal command you would use to kill text. C-x r k kills the rectangle between point and mark. This is the one you want to use.
db48x's user avatar
  • 16.8k
16 votes

How to select and delete a column of text in emacs?

If you select the rectangle, which in Emacs terms means make it an active rectangular region, then C-w does just what you expect. Use C-x SPC to activate a rectangular region that you want to kill. ...
Drew's user avatar
  • 76.4k
9 votes
Accepted

Delete from point to beginning of the line

There is C-0 C-k or C-u 0 C-k. See section (info "(emacs) Killing by Lines").
Marco Wahl's user avatar
  • 2,826
6 votes
Accepted

How to transpose a pair of words?

Some observations first. When asking a question like that you must refer the mode, because the concept of a word depends on the major mode (lookup syntax tables in Elisp documentation). In this case, ...
nichijou's user avatar
  • 1,168
5 votes

Kill URL at point

The url-get-url-at-point function from the url-util (emacs built-in) package should do the job for you. It is used in interactive commands like browse-url-at-point. (require 'url-util) (defun my/kill-...
Kaushal Modi's user avatar
  • 25.4k
5 votes
Accepted

copy region without leading indentation

You basically just want to be calling indent-rigidly on a copy of the region. That will also deal nicely with indent-tabs-mode (which I think you'll find your version does not). I'd suggest using a ...
phils's user avatar
  • 49.7k
4 votes

Allow C-w to kill a region only if it is selected

I think you're looking for: (setq mark-even-if-inactive nil)
Stefan's user avatar
  • 26.3k
4 votes

How can I move/kill multiple chunks of text to the same place/marker, one after another?

A basic option is to use append-next-kill. Rather than killing each region with just C-w (or similar), you instead use C-M-wC-w (i.e. type C-M-w immediately prior to whichever kill command you're ...
phils's user avatar
  • 49.7k
3 votes
Accepted

How can I move/kill multiple chunks of text to the same place/marker, one after another?

I believe you're looking for org-refile (bound to C-c C-w). By default, org-refile will only consider the current file. To refile into another file add the target file with your desired headings to ...
Zeta's user avatar
  • 1,065
3 votes

Kill rectangle with cua-mode support

CUA's help on rectangles (and other things) is slightly hidden away. M-x find-library RET cua-base RET Search the commentary for the section on "CUA rectangle support" (Which is not to suggest that ...
phils's user avatar
  • 49.7k
3 votes
Accepted

What key sequence is killing a large chunk of my buffer?

It is possible that that you're calling kill-region which is bound to C-w. This is what one would consider the cut command in other applications. If the region is not active it will kill from your ...
Jules's user avatar
  • 1,225
2 votes
Accepted

Strange behavior when killling text in term/multi-term

This is not a bug. You can't use emacs commands in term-char-mode, you must toggle to term-line-mode for these commands... But, you can use the terminal commands instead. For example C-w is the ...
djangoliv's user avatar
  • 3,179
2 votes

Kill and yank (append?) text from buffer to bottom of same buffer

I'd rather use standard keyboard short-cuts or the customised solution of @Taylor above, but for completenes sake here are two out of the box Emacs ways: append-to-file: Save your buffer (so it's ...
Dieter.Wilhelm's user avatar
2 votes
Accepted

Delete a line by relative line number

This simple function and keybinding to C-c d will ask you for a number and will delete line that number forward (or backward if you will use negative number): (defun kill-line-relative (&optional ...
Maxim Kim's user avatar
  • 1,721
2 votes
Accepted

Yanking does not use top entry in the kill ring

I don't know why your kill-ring gets messed up. It might be that it is some inter-program action that modifies the kill-ring. But the right way to implement deleting instead of killing is: (defun ...
Tobias's user avatar
  • 32.8k
2 votes

copy region without leading indentation

Use rectangle commands: C-x r M-w Save the text of the region-rectangle as the last killed rectangle (copy-rectangle-as-kill) C-x r y Yank the last killed rectangle with its upper left corner at ...
Left Margin's user avatar
1 vote

Mark up to and including the character under the cursor

In Emacs, the region is defined precisely (and only) as the stretch of text between point and the mark. The only way to achieve what you want is to position point where you want the region to extend ...
Phil Hudson's user avatar
  • 1,701
1 vote

Default yank keyboard shortcut does not work

I am using evil-mode also. Not sure if they interfere. The entire purpose of evil is to make Emacs behave like vi/vim, and a very significant part of that emulation is the different key bindings, so ...
phils's user avatar
  • 49.7k
1 vote

How to limit mark/kill size of huge (org-mode) files?

It's not clear to me why Emacs hangs in what you describe, or what you mean by that. But I think you're talking about accidentally defining a large region of text, and then killing or copying that, ...
Drew's user avatar
  • 76.4k
1 vote

Delete from point to beginning of the line

I have C-<backspace> bound to the following function: (defun phg/kill-to-bol () "Kill from point to beginning of line." (interactive) (kill-line 0)) Basically just the C-u 0 C-k from the ...
phipsgabler's user avatar
1 vote

Delete from point to beginning of the line

M-0 C-k should do what you want.
jidicula's user avatar
  • 251
1 vote

kill rectangle not working on Mac (missing file/library)

Comments on the question post made me understand that the rect library was missing. I looked into brew and tried a brew upgrade emacs and surprise surprise it told me that emacs was not installed,...
ClimateUnboxed's user avatar
1 vote
Accepted

Command that does different things based on whether something is selected

To invoke a function, don't quote it: (kill-whole-line), not ('kill-whole-line). You're looking for function use-region-p, so (use-region-p), not region-selected. (There is no predefined variable ...
Drew's user avatar
  • 76.4k
1 vote

quickly kill and then yank parts of a program

If using evil you can move point to the d and type dt. Another way I often do stuff like this in evil is move point to the d and then go in to visual state with v then move point to where I want (...
izkon's user avatar
  • 1,828
1 vote
Accepted

How to do paredit-kill backwards?

Since no one here has come up with an answer that is sufficient for my needs, I've continued with my aforementioned implementation which uses paredit-backward-delete under certain conditions. What I'...
GDP2's user avatar
  • 1,340
1 vote
Accepted

Kill and yank (append?) text from buffer to bottom of same buffer

I don't think there's anything built-in that's more efficient than this: select text kill selection with C-w move to end of buffer with M-> (i.e., end-of-buffer) yank C-y return to where I started ...
Tyler's user avatar
  • 21.9k
1 vote

Kill URL at point

This is the way to get a run of text with the same face under point: (defun face-under-point () (interactive) (let ((face (face-at-point t)) (start (point)) (end (point)) ...
wvxvw's user avatar
  • 11.3k
1 vote

Kill rectangle with cua-mode support

This one is pretty straightforward, M-k does it. It is not listed in the mini-buffer help, and asking for help with C-? does not show more help. It can be found on this link on rectangle editing with ...
nephewtom's user avatar
  • 2,249

Only top scored, non community-wiki answers of a minimum length are eligible