I thought I'd document the troubles I went through to get my USB mouse working at the Linux console, and then in VIM. I'm running Arch Linux.

GPM
-----------------

The first thing you'll need to do is configure gpm, a mouse server used to provide a service to people who want to use their mouse at the console, so you can copy/paste selections,and move to lines in your text editor, and select menu items in curses applications.
If GPM isn't installed, you can install it through the command :

pacman -S gpm

Open '/etc/conf.d/gpm' with nano or your editor of choice, and add the following:

GPM_ARGS="-m /dev/input/mice -t imps2"

(For a full list of the mouse types you can give to the -t parameter, type 'gpm -t abc', generally, ps2 or imps2 will work for your mouse, but the other options are listed there)

Now, start gpm by entering the command(as root) '/etc/rc.d/gpm start'
Now you should see a square block cursor appear, and be able to highlight text by holding down the left button, and moving it accordingly.

MOUSE WITH VIM
---------------------------------
Now that gpm is working, you can set up vim to recongize your mouse so you can use it in your files. Let's assume you want this change to be permanent, if you don't, simply enter the commands i'll show you by typing ':' followed by the command while you're in the editor.

Open up ~/.vimrc, and add the following :

set mouse=a
:behave xterm

Mouse support will be turned on, and it will behave like an xorg mouse. You can also pass ':behave mswin' if you'd like it to behave like a MS Windows mouse. Now you can use your mouse in VIM.

If you would like support in xterm, turn off gpm as it really isn't needed anymore if you're switching to xorg. To switch gpm off, simply run ;

/etc/rc.d/gpm stop

If you've done the above to configure VIM to support a mouse, your mouse should work straight off in vim on a xterm or an xterm-like terminal, if you have a mouse-scroll, use it :-) It'll work in an xterm terminal, but unfortunetely, mouse scrolling won't work in vim on a console without xorg.

I wanted to document this for myself, because i'm sure i'll need this in the future, if it helps somebody else out there too, great :-)

nice post rpag

arch ftw.

I've used "set mouse=a" before, but sometimes it behaves oddly in my xterm.

For example, sometimes, I have started an xterm shell, executed Vim on a file and been able to scrollwheel down, but the scroll wheel up takes me to the xterm buffer. if I quit, and then execute in that same xterm a "gnu screen" session, and execute Vim in that, mouse support sometimes does not work at all. I checked that the mouse=a was set in the screen and I have been able to use mouse support in the screen some of the time.
-------------------
310-014 | 310-015 | 310-016 | 310-019