0

Question:

Is possible to use mouse to move lines around?

Requirements & Clarification

  1. I do know keyboard solutions.
  • normal mode ddp d2j'}p dapggp alike.
  • cmdline commands, :co. '<,'>m'a etc.
  1. I want this feature -- mouse to move/duplicate/delete lines -- mainly for simple use (do not exceed one page). Here is the workflow, with example of copying vim 8.0 feature from Vim 8.0 is released - Laravel News
  • between chrome and gvim
  • copy in chrome
  • back to gvim, paste
  • nn <buffer> <Tab> p to facilitate the workflow
  • but here is the problem, some line are are whole line, some are not.

The result is like below

Asynchronous I/O support, channels
Jobs

Timers
Partials
Lambda and Closure
Packages

New style tests

Window IDs

In this case, it is more sensible to move lines with mouse.

Of course I can vG:g/^$/d to remove empty lines afterwards.

But I wonder is it possible to move/copy/delete lines with mouse, If possible, I'am also interested to how you community think about the api interface if to create a such plugin.

== Edit ==

step 1, selection

  • double left click select current line
  • with left mouse press, move mouse do selection.

this part is already doen if set mouse=a though the behavior is a little different

  • double click select current word
  • triple click select current line
  • the same as stated above

step 2, duplicate or move selected line.

  • with above step, we are at visual mode.
  • how to move the selected line?

Possible implementation of feature list

  • right click to move selected lines at line that mouse click.
  • with right mouse pressed, contiguously move select lines, maybe use hook on mouse event.
  • right double click to duplicate selected line under line that mouse click.

In summary, how to achive this step 2, this is main point of my question. As for the mouse, someone may prefer use middle click or scrolled instead.

3
  • 2
    I re-read your question a few times and I still can't tell exactly what you want to accomplish... Why do you refer to an external page? Can you show a "before" and "after" of what you want to do? Why do you think using the mouse would be more efficient? What do you have in mind, using right-click for a pop-up menu, or drag and drop, or just click here and there to move a line there? Please edit the question, try to simplify it and keep it focused. Thanks! – filbranden Oct 12 '20 at 2:12
  • As for why mouse in this case more efficient, since my right hand hold mouse to select text in browser, left hand <Alt-Tab> to switch program. use mouse is faster than, since its just one click to move a line above, and the cursor is already there. – qeatzy Oct 12 '20 at 4:51
  • I'm not sure why do you need to move lines around if it's just copy and paste from the browser, but (1) you can remap <LeftMouse> and <RightMouse>; (2) you can map such that empty lines are removed after each paste. – user202729 Oct 16 '20 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.