views:

461

answers:

3

I'm using vim 6.3.81 on a xterm through putty. When I use set mouse=a , I can scroll through the file , but not select text. When mouse is disabled using set mouse=, I can select text with mouse (automatically copied to a buffer) , but if the text block is over one page long , I can't scroll up/down (and have to select text one screen at a time) !!

Is there any way to have the best of both - while selecting text with mouse , if i reach the end of page , it automatically scrolls up/down depending on whether i've reached top/bottom of page and allows me to select text from the next page as well ?

I know vim is powerful/flexible enough to do what I want - I just don't know how !! Can anyone help ?

+1  A: 

Have you thought about selecting using the mouse and then the keyboard? Just

  • Position the cursor using the mouse.
  • Press "v" in command mode.
  • Press Up/Down (or j/k) to move up/down

If you scroll off the end of the terminal, it will automatically scroll down keeping the selection active.

Benj
Two problems: 1) I wanted to use the mouse to show a friend that he can use the mouse in vim , just like notepad and other windows editors. Its easier to remember for a newbie :) 2) Currently , if i select and then copy text in Visual mode , the copied text cannot be pasted in a separate instance of vim opened in a differnt putty session - somehow , copying text through mouse does not have this problem !
shan23
In answer to point 2. The reason it's not a problem when copying with a mouse is because in this case putty (not vim) will be putting the text in the Windows clipboard. If you think about it that makes what you're asking of vim almost impossible because it would have to not only scroll down but would also have to maintain puttys selection which potentially has scrolled off the top of the terminal. When running in terminal mode vim can only effect what the terminal can see and putty can only copy what the terminal shows.
Benj
If you really want to show your friend what vim can do you'd be better off installing an X server on your machine (like Cygwin/X for windows) and then setting your DISPLAY variable in putty and running gvim to run a graphical version of vim straight to your windows desktop, this will behave much more like a windows program etc.
Benj
A: 

Short answer: no, sorry.

Long answer: Vim in a terminal doesn't interact with the windows clipboard, so selecting with mouse=a won't help, as the selected text won't be accessible. Without mouse=a, where PuTTY is controlling the mouse, vim's data isn't in PuTTY's scrollback buffer, so PuTTY can't get at it.

The solution is (as suggested by Benj) to use gvim, either in an X server or using a native install of vim.

Andrew Aylett
+2  A: 

When you have set mouse=a , You can select by <Shift> + LeftMouse to do a selection, <Shift> + RightMouse to paste your code as usual.

Hope this helps !!

Kaillash
Short and sweet !!!
shan23