3

I have been using Vim for a couple of months and I think I've fallen in love with it. But I am still using the mouse for selecting text and scrolling. Every tutorial, advice and blog post I have visited states that it is a bad habit to use the mouse on Vim. Is it really embarrassing to use the mouse in Vim? Does anybody here who use Vim as their primary editor use the mouse?

1
  • I use the mouse mostly for scrolling through code when reviewing (not editing). The only other time I really use it is when I want to resize splits. I have not yet found a mapping I'm comfortable with that works well enough for this.
    – Randy Morris
    Jan 13, 2011 at 19:26

5 Answers 5

8

These tutorials are wrong, and even detriment to learning. Do not try to abjure your previous working style and do everything the “Vim way” from now on. It won’t work anyway and you won’t get any work done.

Just go with it and try to learn more Vim idioms all the time. I’m still using the mouse after years of almost exclusively working in (g)Vim.

8
  • 1
    Some common mouse actions can be replaced with exciting vim commands, but there's really no replacement for the mouse when you want a large visual selection.
    – Cascabel
    Jan 13, 2011 at 18:26
  • @Jefromi: depends on the selection, e.g. most block selections can be handled via vi{, where { is a block delimiter of your choice. But in general I agree with you. Jan 13, 2011 at 18:29
  • 1
    The main and only reason, why you must not use mouse in vim is that moving hands from keys to mouse and back take very long time. With features like setl rnu, /{pat} and other motions it is always faster to use keyboard.
    – ZyX
    Jan 13, 2011 at 20:18
  • 1
    @Jefromi. Use setl rnu (relativenumber). With it you can normally get selections like V53k (assuming that all 53 lines are shown on the screen). If they do not fit, use /{pat}, marks, repeat Hz<CR> until you see target line, ... Mouse will slow you down significantly and prevent from learning neat vim tricks.
    – ZyX
    Jan 13, 2011 at 20:27
  • 1
    @ZyX: you may be right (I don’t know – I rarely use the mouse anyway but sometimes it’s still faster for me) but this doesn’t change that it’s bad didactics and detriment to learning. While it’s true that being thrown into the water will either teach you swim or drown you, the truth is that it will usually drown you. In the case of learning Vim this simply means that you throw your hands up in frustration and go back to some more convenient editor. I’ve been there. And so have countless other people. Jan 13, 2011 at 21:24
6

You should try to use text objects.

I stopped using the mouse more or less once I started using these.

Basically text objects are shortcut to easily execute command on words, sentences, paragaphs.

Just for fun you can try the following :
dip : it will _d_elete (_i_n) the current _p_aragraph
vib : between parentheses, it will select the content than you can then yank, cut, etc
vi} : will select a C block, than you then quickly reindent with = or delete, or decrease indentation...
caw : to quickly delete and replace the next word

Possibilities are endless. See :help text-objects

It is really one of the greatest Vim features and is only rarely highlighted in Vim tutorial. (I learned about them very late, maybe a year or two after starting using Vim)

That being said I still use the mouse sometimes and it is not a cardinal sin.

2

Its really a matter of preference. I sometimes use the mouse, but I find that it is much more efficient to not have to move my hands. If you spend a lot of time in vim, you may want to start learning the keyboard shortcuts and moving around using "hjkl" instead of the arrow keys. It saves you a lot of time.

0

Do you know about Shift-V and then using j or k keys to visually select entire lines at a time? I use this very frequently to yank files.

I use C-F and C-B for scrolling.

I find both more efficient than using a mouse.

1
  • Yeah, I know about the visual mode and selecting lines in it. But I am still not comfortable with it.
    – finemann
    Jan 13, 2011 at 18:49
0

I very seldom use the mouse. Sometimes however I find it very quick to select some portion of text not linewise, from the middle of a line to the middle of another line on my screen.

This is the only use I have for the mouse in vim.

Not the answer you're looking for? Browse other questions tagged .