20

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 M-x delete-file RET <file> RET. Once you have done that refresh the Magit buffer using g and then stage the "deletion" of the file by moving to it in the ...


14

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.


12

Ah yes. Isearch reads the keys you type, looks them up in isearch-mode-map, and invokes them in the current buffer. Isearch does not, in spite of appearances, use the minibuffer. It uses the echo area. That is, what you see there is actually output messages, including echoes of the characters you type. This should do what you ask: (defun mydelete () "...


10

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 word about phils' comment: If it's safe to modify the original list structure, then nbutlast will be slightly more efficient (n.b. you still need to assign ...


7

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 option you can still view the file in Emacs even though it's in the trash can. If this is too redundant I think this answer has the proper solution (although ...


7

You might find the hungry-delete package useful. I personally bind C-cdelete to delete whitespace after point, and C-cbackspace to delete whitespace before point like so (global-set-key (kbd "C-c <backspace>") 'hungry-delete-backward) (global-set-key (kbd "C-c <deletechar>") 'hungry-delete-forward) update: as of 12.2018 function definitions ...


6

The Swiss army knife of Emacs is called keyboard macros. See the Emacs Wiki and the manual. Enter the macro mode, perform the commands of the macro (note: the commands are not only recorded, they are also executed). Steps: Save your file for backup! Go to line 3 of your file Enter macro recording mode : C-x ( Delete this line : M-x kill-whole-line Go down ...


6

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>, M-d. (kill-word ARG) Kill characters forward until encountering the end of a word. With argument ARG, do this that many times. Now, let's ...


5

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 coded as: (defun kill-word (arg) "Kill characters forward until encountering the end of a word. With argument ARG, do this that many times." (interactive "p"...


5

The following is required: (setq delete-by-moving-to-trash t) (setq trash-directory "~/.Trash") The function move-file-to-trash has three tests: (1) whether trash-directory is defined; (2) whether (fboundp 'system-move-file-to-trash); and, (3) (t . . . the catch-all that uses ~/.local/share... The second test always fails on OSX 10.6.8 when built with ...


4

The behaviour of backward-kill-word depends on the definition of a "word" in the current mode. You can either change this definition and risk breaking stuff or you could modify kill-word. backward-kill-word is just kill-word with a negative argument; kill-word is kill-region over the region spanned by point and the position after running (forward-word arg)....


4

This is expected Vim behavior. One way to fix this is to just switch to d e instead of d w when you get to the EOL (which I recommend), or you can make that switch automatic: (defun nadvice/evil-forward-word-begin (old-fun &rest args) (if (looking-at "[[:space:]]*$") (progn (apply #'evil-forward-word-end args) ;; fix off-by-one ...


4

I use this quite often: (defun join-line* () "Join this line with the next line deleting extra white space." (interactive) (join-line t)) (global-set-key (kbd "M-j") #'join-line*) ;; just key binding I use…


4

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 mention that n=15?


4

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 the region instead of just deleting the character before/after the cursor. That is, move to one end of the text you want to delete, press Ctrl+Space, move to ...


3

Define the function system-move-file-to-trash in this way should be enough: (defun system-move-file-to-trash (file) (call-process "trash" nil nil nil file)) if you don't have trash installed, Emacs will tell you. then, don't set the variable trash-directory since trash does that for you. About Emacs's trash behavior: move-file-to-trash is an ...


3

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.


3

The following function (briefly tested) will allow you to delete lines with a starting value and a step value: (defun delete-some-lines (&optional start step) "Delete lines starting with START at STEP intervals." (interactive) (let ((lines (list (or start (string-to-number (read-string "Starting line: "))))) (step ...


2

If you use library Dired+ then the delete key is bound by default to to command diredp-delete-this-file, which deletes the file named on the line of the cursor, after confirmation. (C-k is bound to the same command.) This is the entire definition of the command: (defun diredp-delete-this-file () ; Bound to `C-k', `delete' "In Dired, delete the file ...


2

Yet another solution (defun foo () (interactive) (delete-region (point) (+ (save-excursion (skip-chars-forward " \n")) (point))))


2

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.


2

I have tested in emacs -Q that C-u <backspace> will delete 4 spaces backwards. Equivalent bindings would be: M-4 <backspace> C-4 <backspace> Before int main () { ▮int a = 0; (▮ represents point) Do C-u <backspace> or C-u DEL. After int main () { ▮int a = 0; By default C-u represents a repetition or 4 for most commands (...


2

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 arg) "Kill relative line." (interactive "n") (save-excursion (forward-visible-line arg) (kill-whole-line))) (global-set-key (kbd "C-c d") 'kill-...


2

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" "" (filter-buffer-substring beg end)))) (if (string-match-p "^\\s-*$" text) (evil-delete beg end type ?_) (evil-delete beg end type reg yank-...


1

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 not help. It explains how to do it with Lisp, in various ways. It explains how to do it with the UNIX / GNU/Linux command sort or unique.


1

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 want to delete entire lines, you'll need to include a newline in your regexp. You enter this at the prompt with C-q C-j. So, for over_second, call C-M-%, then ...


1

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've come up with isn't very pretty (nor very efficient), but it works well enough and seems to keep true to the spirit of paredit from an end-user perspective. ...


1

I came from sublime as well and was looking for the behavior. I achieve the results you are describing by using syntax-subword which I think can be installed through MELPA. Here is my syntax-subword configuration (I use use-package): (use-package syntax-subword :init (setq syntax-subword-skip-spaces t) :config (global-syntax-subword-mode)) For you, ...


1

The normal way to fix this is to fix py-electric-backspace to check use-region-p and delete-active-region and handle them as expected. IOW, I'd submit a bug report to the maintainers of the package.


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