Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i'm not very experienced in VIM. i'm using VIM with putty, and i often use mouse scroll and move text cursor with mouse. also sometimes i need to paste some code from windows clipboard, so i have to type ":set mouse=" to turn off mouse handling in VIM, paste the code with right mouse button and then turn mouse handling on again with ":set mouse=a". i'm looking for a better way to do it.

share|improve this question

migrated from stackoverflow.com Oct 14 '09 at 18:55

This question came from our site for professional and enthusiast programmers.

4 Answers 4

Simply by <Shift> + LeftMouse to do a selection, <Shift> + RightMouse to paste your code as usual (set mouse="" state)

share|improve this answer
    
I have no idea why I didn't think to suggest this! +1 –  Jefromi Oct 15 '09 at 18:29
    
I have been looking for this answer for months. Thanks! –  cori Feb 13 '11 at 3:44

Here's an excerpt from my vimrc. It maps a key to toggle the mouse mode between vim and external handling ("a" and ""). It's mapped twice so that it works both in normal and input mode, and it echoes which mode you've ended up in (though that'll be obscured in insert mode if you have showmode turned on).

" toggle between terminal and vim mouse
map <silent><F12> :let &mouse=(&mouse == "a"?"":"a")<CR>:call ShowMouseMode()<CR>
imap <silent><F12> :let &mouse=(&mouse == "a"?"":"a")<CR>:call ShowMouseMode()<CR>
function ShowMouseMode()
    if (&mouse == 'a')
        echo "mouse-vim"
    else
        echo "mouse-xterm"
    endif
endfunction
share|improve this answer

Most VIM purists would tell you: "Stop using the mouse for movement then".

Hopefully someone who uses the mouse in VIM can help you with making the mouse stuff work better, but if you're interested, I suggest the following helpful key combos to make moving your cursor/view easier in VIM:

h,j,k,l: left, down, up, right.
H: Move cursor to the top of the visible screen.
L: Move cursor to the bottom of the visible screen.
G: Move cursor to the bottom of the file.
gg: Move cursor to the top of the file.
$: Move cursor to the end of the current line.
0: Move cursor to the very beginning of the current line.
^: Move cursor to the first non-whitespace character of the current line.
Ctrl + f: Move forward/down one page.
Ctrl + b: Move back/up one page.

Hopefully those help free you from the mouse, if you're interested, if not, hopefully someone has some mouse suggestions.

share|improve this answer
    
I'd consider myself a Vim purist - and more to the point, a general mouse-avoider - but I think you'll find that for making large visual mode selections with interesting endpoints, the mouse is probably faster, even if you know that you can manage it with something like vL3kf'2w. –  Jefromi Oct 14 '09 at 19:39

This tutorial here is quite good http://www.vi-improved.org/tutorial.php

It's a log of someone teaching someone over chat so it goes through things slowly.

share|improve this answer
    
This is a vim tutorial. It doesn't contain anything regarding the question. –  innaM Oct 14 '09 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.