开发者

Help with deleting in Emacs

I want to delete everything up to the cursor or after the cursor or everything开发者_JS百科 but selected text.


What you want sounds a pretty infrequent thing to be done, but here are a few ways to do it:

First, put cursor on start of text you want to keep. Press C-space to set mark. Then, use M-< (beginning-of-buffer) and afterwards C-w (kill-region-x). Now, everything before text is deleted.

Next, go to end of text and set mark once again with C-space. Now, go to end of buffer with M-> and once again delete everything with C-w.

This is one way to do it.

Other way is to simply copy selected text and put it into new buffer. I'll leave it to you as an exercise.


To keep only the selected text:

C-w C-x h C-w C-y M-y

In other words, kill the selection, select what remains, kill that, then yank the previous selection.


Everything after "the cursor" (aka "point") is deleted using C-k (kill-line). To kill the line up to point, give a 0 argument like this: C-u 0 C-k.

I don't know if there's a way to kill only things that aren't selected. Maybe some kind of "invert-region" before hand?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜