Selecting up with a mouse in vim

Discuss Applications
Post Reply
TheQuirk
programmer
programmer
Posts: 113
Joined: Wed Jan 22, 2003 4:11 pm

Selecting up with a mouse in vim

Post by TheQuirk » Tue Oct 23, 2012 3:38 pm

When I do :set mouse=a, I can drag the mouse down to select text below the current bottom line (vim just scrolls down). I can't do the same when I drag my mouse up. Is there any way to change this behavior?

User avatar
Basher52
guru
guru
Posts: 912
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Selecting up with a mouse in vim

Post by Basher52 » Wed Oct 24, 2012 3:22 am

If you mean that when clicking the last charcter on the last row in vi/vim then want to mark text upwards in that file it starts scolling "the old text" that was shown before you got into the file? I also get that
And how do you do this 'set mouse=a' if you mean that this will scroll the vi/vim-edited text down so you can select rows below the last one you see? 'cos I got big problems selecting all rows that way.

User avatar
Basher52
guru
guru
Posts: 912
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Selecting up with a mouse in vim

Post by Basher52 » Fri Oct 26, 2012 8:48 am

Found something :) and pay attention to the old text.
Lots of Tips & Trick here: http://www.cs.swarthmore.edu/help/vim/home.html
text selection

If you want to do the same thing to a collection of lines, like cut, copy, sort, or format, you first need to select the text. Get out of insert mode, hit one of the options below, and then move up or down a few lines. You should see the selected text highlighted.

V - selects entire lines
v - selects range of text
ctrl-v - selects columns
gv - reselect block

After selecting the text, try d to delete, or y to copy, or :s/match/replace/, or :center, or !sort, or...

Here's one way to move selected text over a few spaces:

- select a chunk of code using capital V and the arrow keys (or j, k)
- type colon
- then type s/^/ /
- hit return

What you've done is replace the beginning of each selected line (the ^ symbol means "the beginning of the line") with spaces.

Post Reply