Using a mouse in Vim
You can enable mouse support in Vim with
set mouse=a in your
.vimrc. The A stands for All modes and will allow the mouse to be used everywhere in Vim.
Is this a joke? Yes. It’s April 1st after all. But also, no. This actually works. And you might find it useful.
Why would you want mouse support in an editor designed for maximum productivity with the keyboard? Well, some people just like that sort of thing. We don’t judge (Narrator: “They judged”).
But in all seriousness, if you’re coming from another editor, you may be accustomed to reaching for the mouse. When starting out with Vim, having the mouse just work is a useful crutch. As you slowly get more efficient with the keyboard, you might consider disabling the mouse with
set mouse= to allow the mouse in no modes.
Here are some things you can do with the mouse in Vim:
- Click and drag to visually select text
- Click tabs to switch focus to a different tab
- Close tabs by clicking the X which will now appear
- Resize splits just by dragging the divider
Watch the brief screencast below to see the mouse in action inside in Vim. Hey, maybe this actually is useful!
Thanks to VimTricks reader Bill for suggesting this tip. We’d love to know what Vim tips and tricks you have. Email us!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?