Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2003 · complexity basic · author pagaltzis · version 6.0
If, like me, you don't want to use the GUI vim because you work in an xterm most of the time anyway, you may be annoyed at the shortcomings this presents. For example, during my webbrowsing, I'll often fire up vim in one of the already lying around xterms to conveniently write a long text (such as this one), and then paste from vim into a textfield on a HTML form in the browser.
The first problem is caused by line numbering, which I keep enabled at all times.
Normally, if you try to copy text out of the xterm that vim is running in, you'll get the text as well as the numbers. The GUI version gets this right: it only selects the text, keeping the line numbers out of the picture. But I don't want the GUI version. So instead, I added this to my vimrc:
Much better. You can also selectively enable mouse support for specific modes only by using something other than 'a' (for 'all').
Now although I'm more of a keyboarder, when I juggle text between X apps (or maybe between xterms), it's just more convenient and efficient to keep my hands on my mouse, since they're there anyway. Now, if you own a moderately recent model, you'll know this lovely little wheel they have (which usually also doubles as mouse button 2). Rolling it scrolls the window in GUI vim, which simplifies life when selecting several, distant passages to paste one after the other. But I don't want to use the GUI vim - you can imagine my delight when I ran across this in the vim documentation:
It involves adding a couple mappings to your vimrc and corresponding VT100 translations to your .Xresources file as a prerequisite. Don't forget
$ xrdb -load .Xresources
after you edit the file. The running xterm will not heed the changes; you need to open a new one to see the effect.
The wheel may not work with the mappings as described in the helpfile. They worked without a hitch for me at first (using Xfree 4.1 then), but broke after I upgraded my distro. Whether it was the switch to 4.3 on this binary has been built with different options, I don't know. At any rate, I had to experiment a bit with the list from
After a bit of trial and error, I finally fixed them by substituting <xCSI> for <M-Esc>:
:map <xCSI>[62~ <MouseDown> " etc " ...
Done. Load a large text file and marvel at mousewheel scrolling.
Re pasting into an xterm vim.
Select text in your browser, goto vim, :set paste, insert mode, middle click (button 2).
If you don't set paste mode, you're probably not going to be happy with the results due to indentation and whatnot. I use F11 to toggle paste mode, in both insert mode and normal mode. From my vimrc:
" F11 to toggle paste mode map <F11> :set invpaste<CR> set pastetoggle=<F11>
A good article about the paste problem: http://www.tummy.com/journals/entries/jafo_20060727_145450 Summary: Use gvim -v in terminal if you want mouse support that works properly!
If you want ":set mouse=a" to work over SSH, just use the '-X' option when using SSH.
If using vim in xterm and having set mouse=a, you will notice mouse middle-click paste no longer seems to work. Instead use Shift+middle-click to paste X selection.