":set mouse=a" is used to enable mouse scrolling/selection. But I have to retype this command every time I enter a new vim session. What can I do so that ":set mouse=a" is by default enabled whenever I enter vim?


Just write so in your .vimrc

If you dont have one just create one in your user directory ($HOME)

Edit: Anyway I recommend you not to do that. Vim has been created with a mouseless philosophy. And you can still scroll with the mouse thanks to the shell (I guess).

Try to get used to these shortcut keys:

<c-u> Move page up

<c-d> Move page down

<H> First line in your windows

<M> Middle line in your windows

<L> Lowest line in your windows

<gg> go to the beginning of the file

<G> go to the end of the file

<zz> Adjust the windows so the line you are on is now the middle line

:<number-line> go to that line (Use this while :set number is activated)

<number<h,j,k,l>> move that number of lines in that direction, so 5j go 5 lines dow (Use this while :set relativenumber is activated) 

If you want to select lines you can still use the mouse if you want to copy some text (Thank to the shell) Anyway if you want to select some lines in order to work with vim commands, then use the visual mode.

(From normal mode)

<v> - (regular) Visual mode. As you move text will be selected

<V> select by lines

<c-v> select by blocs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.