Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [deletion]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

emacs 28.2: how to delete the first 32 char of each Line [duplicate]

I need to delete the first 32 char of each line that compose my file. Can someone explain me how to do that? I've also read How to delete the first few n chars of every line? this answer, but didn't ...
0 votes
0 answers
14 views

can not delete emacs tmp file

I have created a file by emacs29.3 in ubuntu (running in virtualbox). That folder is a share folder from windows11. Today I deleted the ubutun22.04 and installed a new ubuntu24.04 and add the same ...
0 votes
0 answers
20 views

Cant' delete files/directories on Synology

I'm on macOS 14.4.1 and have Emacs 29.2 plus installed from Homebrew. I have an access problem with Dired on my Synology when I try to delete files: "file-error: Removing old name: Operation not ...
1 vote
1 answer
173 views

Delete trailing whitespace on save, but only for yaml files

I would like to run delete-trailing-whitespace for files with extension .yaml only. Can someone please supply the elisp to do this?
1 vote
1 answer
314 views

How can I create a window that can't be closed?

I create a window with the following (setq ook-window (display-buffer-in-side-window buffer '((side . bottom)))) (set-window-dedicated-p ook-window t) But then when I go to the main window and ...
9 votes
4 answers
2k views

How to delete all whitespace up to the first non-whitespace character?

I'm looking for an emacs function that will delete all whitespace from the cursor position (including newlines) until the first non-whitespace character. For example, if my cursor is positioned at ...
0 votes
1 answer
65 views

evil-delete-line deletes hidden children in org-mode

Calling evil-delete-line from a headline is deleting hidden children. Same behavior with evil-change-line. On a collapsed outline tree how can I delete from the cursor to the end of line while keeping ...
3 votes
1 answer
288 views

Deleting a file to ~/.Trash produces "File already exists..." if a file of that name is there [duplicate]

I have (setq trash-directory "~/.Trash") and (setq delete-by-moving-to-trash t) in .emacs to be able to have files moved to ~/.Trash via d and then x in dired-mode. (This is in macOS.) But ...
2 votes
1 answer
264 views

How to create/use extra modifier keys or get a similar functionality to modifier keys?

I want C-d to act as a kind of modifier for the <left> and <right> arrow keys in a similar way to how Shift is a modifier that allows letters to be capitalized. Shift Analogy When I press ...
0 votes
3 answers
117 views

How to delete all the files matching regular expression in elisp?

I want to make some clean-up with auto-generated files. How can I delete all the files matching some regexp mask from within elisp? As an example of desired functionality... Something like the line ...
2 votes
0 answers
74 views

Delete Text by Fading It

I once saw a feature in Vim where, when I delete the text to the left of the cursor, the text is indeed deleted. However, a faint impression of the text remains in its original place, as shown in the ...
2 votes
2 answers
173 views

Automated trim of 28 million text records

I have a plain text data file, consisting of 28 million tab-delimited records, each containing nine fields. The left ends of the first three records look like this: I would like to truncate each of ...
1 vote
1 answer
71 views

delete backwards until indentation

In my config I have (bind-keys* ("C-<backspace>" . (lambda () (interactive) (kill-line 0)))) which deletes the entire line backwards until column position 0. I would like to only ...
0 votes
0 answers
26 views

How to delete a function on which a cursor is in Spacemacs?

Let's say I have this: (defn -main [& args] (my-func|tion 5) (my-function-2 "hello") (third-function-of-mine nil)) where | is my cursor. And I want to delete (my-function 5). So in ...
0 votes
2 answers
177 views

How to unbind and then repurpose a default keybinding?

I want to test out a few alternative keybinding setups but I’m not sure what the simplest/most effective way to do that is. I would like to have it so that instead of C-d being forward delete ("...
1 vote
2 answers
135 views

How to randomize the order of elements in an alist?

I'm using ielm inside Emacs to randomize an associative list. I'm getting duplicate entries a lot of the time, not sure what I'm doing wrong? (defun q () "Q." (let ((alist)) (setf ...
9 votes
3 answers
1k views

Automatic deletion of backup files

When editing files, some foo.bar~ backups appear (files ending with a tilde ~). How can I control their creations, and is it possible to ask for a recursive bulk deletion of all files from a ...
0 votes
0 answers
18 views

Undo insertion and deletion in one step when undoing overwrite of selection

Undoing the insertion of a character while the region is active (and delete-selection-mode is non-nil) requires two steps: the first to undo the insertion and the second to restore the deleted region. ...
2 votes
2 answers
215 views

I want when "C-w" is pressed, execute delete-backward-char when no region is selected and kill-region when the region is selected

Similarly, I want to delete word backward when C-u C-w is pressed. I would also value recommendation on cut/paste/kill conventions. I tried to bind C-w to delete-backward-char, but kill-region stopped ...
0 votes
1 answer
235 views

How to delete inserted directory names for `find-file` input?

I've been trying to figure out how to erase directories faster when I use find-file in vanilla Emacs. An example is Doom Emacs, you press backspace once, and erase the entire directory, but when I try ...
3 votes
2 answers
336 views

Deleting words while preserving clipboard

Is there a way to keep the clipboard contents when deleting entire words with M-DEL? For instance, I'd like to delete a word (M-DEL) and then paste (C-y) what I had previously copied (with ctrl+c) ...
1 vote
1 answer
64 views

Delete all non-word characters between two words

I am often in a situation where there are two words with a bunch of symbols in between like this: word1|); }; } word2 Now I'd like to delete those symbols + whitespace between the words and maybe ...
10 votes
4 answers
2k views

Delete files to Trash on OS X

Is there a best, most future-proof method of setting emacs on OS X to delete files to the trash? I tried the instructions here: (setq delete-by-moving-to-trash t) (defun system-move-file-to-trash (...
6 votes
4 answers
715 views

How to do paredit-kill backwards?

Most everyone who uses paredit has used paredit-kill (i.e., C-k), which allows one to delete a line forwards whilst keeping delimiters balanced properly. But how does one do this in the reverse ...
13 votes
4 answers
3k views

Backspace without adding to kill ring

Using Crtl+Backspace or Ctrl+Del adds the deleted text to the kill ring. How can I prevent this from happening? I do not need to have every single piece of text sent to the kill ring when it gets ...
1 vote
2 answers
273 views

How to delete the contents of a buffer by name

For example in gdb mode, there is a buffer named *input/output of <program name>*, that I want to clear each time I press C-c l.
2 votes
1 answer
359 views

How to bind C-h to delete-backward-char when doing isearch?

I use C-h as an alias for delete-backward-char everywhere. But when I do isearch it exits the search instead of deleting the character before the cursor. I tried binding C-h in isearch maps, but ...
11 votes
3 answers
3k views

Removing the last element of a list

Is there a simpler way to remove the last element of a list than this? (setq list (reverse (cdr (reverse list))))
0 votes
1 answer
85 views

Make org-delete-char (C-d) delete extra space after deleted word

Hitting C-d (org-delete-char) in an Emacs org file deletes the word following the cursor. I would like to delete the extra space left also without having to use DEL. I.e. one action to delete word and ...
6 votes
3 answers
3k views

Delete from point to beginning of the line

Have read the GNU manuals on erasing, killing, and deleting. In bash C-u deletes from the cursor to the beginning. I have searched and in much disbelief can't find out what the equivalent is in emacs?...
48 votes
2 answers
12k views

Git rm from magit

This is a very basic but I have been unable to find the answer on the web. Is it possible to git rm, i.e. to remove a tracked file, from magit? Thanks
2 votes
2 answers
906 views

Evil - don't yank with only whitespace to register

How can I configure Emacs in Evil mode to delete an empty line (d d) without copying it but still copy it when deleting a non-empty line?
2 votes
1 answer
196 views

Why Emacs (dired+) asks me twice to delete file?

windows 10, Emacs 26.1, dired+ Suppose I want to delete (move to trash) file in dired mode. D Emacs asks me: I press y and now it's asking me again to kill file. Why Emacs asks me twice? I want ...
3 votes
3 answers
594 views

Delete duplicate lines, with partial match

Sample text: This is first line.a This is over_second line. This is over_fourth line. This is third line. This is over_fourth delete it. This is over_fourth and one more. This is over_second with ...
1 vote
0 answers
170 views

How to delete a long region by setting a mark and then searching for the location of the end of the region?

I have a long document. I placed two unique identifiers, in the form of short strings of printable English letter, in two positions in the document. The identifiers are far apart. My task is to delete ...
1 vote
0 answers
138 views

vlf-mode, delete up to end of file

I am viewing a large file (512 MB) with vlf-mode. How can I delete from a point of the file to the end? The standard approach of selecting the text from a point to the end and then deleting it does ...
0 votes
1 answer
97 views

How to trim text on each line, starting with the first space

Windows 10, Emacs 25.1 Suppose I has text: Advertisment d184f52a-14d7-dddddddddd ZAnelik 1c970d12-6c67-44e1-cccccccccccc Avers b0f0dd6b-a43f-4e40-b0ebbbbbbbbb BAVERS_MIGOM_OLD ...
1 vote
1 answer
124 views

Delete a line by relative line number

I'm looking for solutions/suggestions on how to delete a line not under cursor but by relative line number. For example, how to delete the line which is 5 lines after the cursor without going to it in ...
1 vote
1 answer
669 views

how remove all but the first n chars

How can I remove all but the first n characters of a every line in the file buffer? What I tried Mark region C-x r k #but this is cumbersome when the length of lines are very varied, and there are ...
0 votes
0 answers
156 views

What is causing `delete-trailing-whitespace`?

In some buffers (e.g. diff buffers) the trailing whitespace is essential to the format and must be preserved. What is causing Emacs to invoke delete-trailing-whitespace whenever I save the buffer? ...
1 vote
2 answers
1k views

Rebind backspace to C-d for deleting char backwards

I want to delete char backwards using C-d, not the backspace key. I could do it like that: (global-set-key (kbd "\C-d") 'delete-backward-char) However, I have noticed that in fact backspace points ...
2 votes
1 answer
2k views

Delete 4-spaces as a single tab

I asked another question yesterday but this bothers me a little. I use 4 spaces as indentation for programming (ShellScript, C and Python, mostly). When I want to delete the 4 spaces, I had to do one ...
2 votes
1 answer
154 views

Kill like vim or Sublime Text

I'm "new" with Emacs. I'm making my own set up but I can't do one thing with killing words. You know what M-DEL does by default, but I want to make like Sublime Text or VIM. I'll do an example (this ...
2 votes
1 answer
448 views

How to stop C-backspace or M-backspace from copying text?

Deleting a chunk of text from the cursor causes the deleted contents to be copied into the kill ring, overwriting whatever I had stored there. How do I stop this from happening?
5 votes
4 answers
3k views

How can I delete specified lines?

I want to delete lines with number 03,08,13,18,...., 3+5n. How can I do that? Thank you very much.
1 vote
2 answers
90 views

Make delete button to delete file at point in dired?

In normal file managers like nautilus, if i select an item and press delete button, it will delete that item. How can i achieve the same in dired? When point is at file, pressing delete button should ...
1 vote
1 answer
865 views

How to delete word in next line with evil-mode?

I use evil-mode (from spacemacs) and I get a strange behaviour which I'm not sure if it is right or a bug. If I delete words (with dw, i think it calls evil-delete), it works until I arrive at the ...
1 vote
1 answer
168 views

Delete marked region with py-electric-backspace py-electric-delete

In my python-mode the backspace and delete keys gets remapped to py-electric-backspace, etc. This breaks the behaviour set by the variable delete-active-region. Is there a way to unify the behaviour ...
12 votes
1 answer
710 views

Delete portion of Isearch string that does not match, or last char if complete match

I have the following (defun isearch-del-fail-or-char () "Delete failed isearch text, or if there is none, a single character." (interactive) (if (isearch-fail-pos) (delete-region (isearch-...
7 votes
1 answer
715 views

backward-kill-word ignores whitespaces, is there another friendlier version?

Emac's backward-kill-word tends to delete more than I want. E.g when I press delete multiple times on this: (key-chord "qf" 'helm-org-in-buffer-headings) ;heading search. | I get: 1. (key-chord ...