wyuenho / move-dup Goto Github PK
View Code? Open in Web Editor NEWEmacs minor mode for Eclipse-like moving and duplications of lines or selections with convenient key bindings.
License: Other
Emacs minor mode for Eclipse-like moving and duplications of lines or selections with convenient key bindings.
License: Other
I think this function is more useful for me.
(defun md/duplicate-up-then-comment ()
(interactive)
(md/duplicate-up 1)
(comment-region (line-beginning-position) (line-end-position))
(next-line 1))
Before
(global-set-key [(shift return)] 'md/duplicate-up)|
After
;; (global-set-key [(shift return)] 'md/duplicate-up)
(global-set-key [(shift return)] 'md/duplicate-up)|
Hi:
I have been using move-dup
as a replacement for move-text
. But there is an issue when I try to move empty lines, because they are not recognized and are not moved. Commands like md-move-lines-down
only moves non empty lines.
Comparing the codes the main difference sems to be that move-text
uses transpose-lines
for lines like:
(defun move-text-line-up ()
"Move the current line up."
(interactive)
(if (move-text--at-last-line-p)
(let ((target-point))
(kill-whole-line)
(forward-line -1)
(beginning-of-line)
(setq target-point (point))
(yank)
(unless (looking-at "\n")
(newline))
(goto-char target-point))
(let ((col (current-column)))
(progn (transpose-lines 1)
(forward-line -2)
(move-to-column col)))))
(defun move-text-line-down ()
"Move the current line down."
(interactive)
(unless (or
(move-text--at-last-line-p)
(and
(move-text--last-line-is-just-newline)
(move-text--at-penultimate-line-p)))
(let ((col (current-column)))
(forward-line 1)
(transpose-lines 1)
(forward-line -1)
(move-to-column col))))
I use the global mode, but in some modes I want to disable it (like in org-mode, where it messes up the subtree-moving binds). I tried putting both (move-dup-mode)
and (move-dup-mode nil)
in my org mode-hook, but neither one disables the minor mode.
I don't know a lot about elisp or making modes, but from what I can tell, move-dup-mode
doesn't accept nil
to disable it. It would be really helpful if it did, like several other minor modes do. :)
Thanks.
I replaced move-test
with move-dup
in my config and I've generally been quite happy. One thing that bugs me, though, is that md/move-lines-up
and md/move-lines-down
work differently when the region is active and when it is not.
With a region active, I can repeatedly run md/move-lines-up
and the same region will move up each time. However, with no region active, the currently line moves up but the point remains on the same display line, so running md/move-lines-up
again just undoes the previous action.
I suggest that it would make more sense for the point to remain at the same position within the moved line when the region is inactive. What do you think?
When point is on the last line move up doesn't work
installed package, added the following to config, but only works if enabled in the minibuffer. Tried all suggestions in the readme, nothing works:
(require 'move-dup)
(global-set-key (kbd "M-<up>") 'md-move-lines-up)
(global-set-key (kbd "M-<down>") 'md-move-lines-down)
(global-set-key (kbd "C-M-<up>") 'md-duplicate-up)
(global-set-key (kbd "C-M-<down>") 'md-duplicate-down)
After doing
(require 'move-dup)
(global-move-dup-mode)
the command
md-move-lines-up
is not recognized as such
while
move-dup-move-lines-up
is recognized (and it works)
ditto for the other three md-
commands
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.