35
votes
Git rm from magit
Magit does not provide a command that does git rm (but if you opened a feature request, then I would probably add it eventually).
Meanwhile you can delete the file using some other method, e.g. using ...
22
votes
Git rm from magit
Magit doesn't support git rm. Instead, delete the folder in dired, and then stage the change.
You can also use ! to launch any git command.
17
votes
Accepted
Removing the last element of a list
Yes there is:
(setq list (butlast list))
That is a function from subr.el. (Loaded by default. No need to load anything.)
You can also cut a tail with N elements by
(setq list (butlast list N))
A ...
11
votes
Accepted
Backspace without adding to kill ring
According to the documentation:
<C-delete> runs the command kill-word (found in global-map), which is
an interactive compiled Lisp function in ‘simple.el’.
It is bound to <C-delete&...
10
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").
7
votes
Accepted
Why Emacs (dired+) asks me twice to delete file?
So when you open a file it creates a 'buffer' with the file's contents. The first yes moves the physical file to the trash. But the 'buffer' is still loaded in Emacs. If you say no to the second ...
5
votes
Backspace without adding to kill ring
Since Emacs 24, without any configuration, you can delete any text without adding it to the kill ring by selecting it and then pressing Backspace or Delete. When the mark is active, these keys delete ...
5
votes
How to stop C-backspace or M-backspace from copying text?
If you look at what M-backspace calls using C-h <M-backspace> you see that it calls backward-kill-word that function simply calls kill-word with a negative argument. The kill-word function is ...
4
votes
how remove all but the first n chars
You can do a replace-regexp like this:
replace ^\(.\{15\}\).*$
with \1
This will match lines with at least 15 characters, and replace with the 1st 15 (which are saved as a match group).
Did you ...
4
votes
Accepted
I want when "C-w" is pressed, execute delete-backward-char when no region is selected and kill-region when the region is selected
Taking you at your word, that you want to delete, and not kill, for the char and word cases, try this.
(Killing is like "cut" - it not only deletes the text but puts it on the kill-ring, ...
4
votes
Accepted
Automated trim of 28 million text records
For the curious, there is a csv-mode that can be used to remove the unwanted columns, but it's not going to perform very well on a file with 28 million records in it. (I tried.)
The Emacs Way
...
3
votes
Delete all non-word characters between two words
Select the region where you want this occur, and
M-x query-replace-regexp \W+ RET <space>
C-M % \W+ RET
Other solution :
Evaluate and save in your init file :
(defun removes-all-no-letter ()
...
3
votes
How can I create a window that can't be closed?
Ok, I have figured it out. I need to add this line :
(set-window-parameter ook-window 'no-delete-other-windows t)
As referenced in this issue.
3
votes
Accepted
Evil - don't yank with only whitespace to register
You can try this.
(evil-define-operator evil-delete-without-register-if-whitespace (beg end type reg yank-handler)
(interactive "<R><y>")
(let ((text (replace-regexp-in-string "\n" "" ...
3
votes
Delete files to Trash on OS X
I've been using the osx-trash package. It works with or without the trash command line utility, and integrates properly with the macOS Trash directory.
3
votes
How to trim text on each line, starting with the first space
You can use C-M-% (query-replace-regexp) to delete text matching the pattern " .*$". i.e., everything, starting with whitespace, up to the end of the line.
2
votes
How to delete all whitespace up to the first non-whitespace character?
C-k M-\
C-k - Kill rest of line or one or more lines (kill-line).
M-\ - Delete spaces and tabs around point (delete-horizontal-space).
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 ...
2
votes
Delete duplicate lines, with partial match
Try delete-duplicate-lines, which is part of distributed Emacs.
Emacs Wiki page Duplicate Lines might help.
It points to a blog post about it.
It explains why interactive search-and-replace might ...
2
votes
Deleting words while preserving clipboard
In modern versions of Emacs, by default, delete-backward-char (DEL, i.e. BackSpace) deletes the region if it is active. So you can delete instead of killing by selecting, then pressing DEL. If you ...
2
votes
Deleting words while preserving clipboard
No. M-DEL is bound to the function backward-kill-word, which calls kill-region. Anything that calls kill-region puts the killed text into the kill-ring, and also into the system clipboard. This is ...
2
votes
Automated trim of 28 million text records
How are the fields delimited? Several spaces, or one tab?
Consider using cut, specifically cut -f (by field) rather than emacs.
1
vote
Removing the last element of a list
Another solution would be to use dash.el's slicing:
(setq list (-slice 0 -1 list))
I don't know if this is too much 'soy' for those hardcore lispers, but -slice really takes the hassle out of lists ...
1
vote
Accepted
How to delete the contents of a buffer by name
In general, if you don't know the exact name of the buffer, you need to call buffer-list to obtain the list of buffers and filter the result to only act on the desired buffer(s).
Untested code:
(defun ...
1
vote
Accepted
How to bind C-h to delete-backward-char when doing isearch?
First, in general, Isearch uses the minibuffer only for M-e. So your minibuffer-local-isearch-map key binding is useless here. That's the keymap used when editing after M-e.
Second, your isearch-...
1
vote
Make org-delete-char (C-d) delete extra space after deleted word
Despite that's not the documented behavior for org-delete-char which deletes only chars and no words adding spaces only inside table cells, you could achieve what you want doing either:
defining a ...
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 ...
1
vote
1
vote
Delete duplicate lines, with partial match
If you don't need to do this all the time, the quickest solution might be using interactive replacement: query-replace-regexp, bound to C-M-%. Start with point at the top of the buffer.
Note, if you ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
deletion × 46key-bindings × 6
evil × 4
spacemacs × 3
region × 3
whitespace × 3
kill-text × 3
lines × 3
org-mode × 2
indentation × 2
dired × 2
regular-expressions × 2
osx × 2
search × 2
files × 2
text-editing × 2
isearch × 2
copy-paste × 2
list × 2
mark × 2
kill-ring × 2
words × 2
large-files × 2
magit × 1
python × 1