Let the mouse go!

And start using your keyboard!

Pietro Scarampella

--

There is a long story, but I care for your time and will go for the short one: I’ve got wrist pain due to bad mouse habits and a night in February a guy named Jacopo Romei (re)introduced me to VIM.

Now, It’s not like I’ve abandoned a fancy modern IDE in favour of VIM, and to be honest, maybe VIM it’s not even mandatory to use a modern IDE without a mouse, if you, like me, are using an Intellij product then you can learn a lot with the following talk of Hadi Hariri

But you can do the extra mile and install a handy plugin to bring VIM into your IDE like IdeaVim (There is one for vscode too)

Now, assuming that you are learning the basic of VIM, I suggest you as the first thing to open a terminal and run vimtutor , which helps you grasp VIM basics like movement, modes, and more. It’s even accessible via the web here

Once you’ll be set up and ready to go, here you’ll find some advice that I’d like to have when I started.

Forget about arrow keys
Force yourself to use the navigations key h j k l instead of arrow left, down, up, right and to do so disable the arrows key adding these options into your .vimrc file.

noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Right> <NOP>
noremap <Left> <NOP>

Of course, you need to throw your mouse away.

Note: if you are using IdeaVim, the configuration file is .ideavimrc where you can add a source .vimrc to use the default used by VIM

Tip: After I get used to h j k l I also mapped the left, down, up, right movement in the idea Keymap with ctrl+k, ctrl+j, ctrl+h, ctrl+l to navigate through dialogues and other windows such as the project panel without moving my hands from the keyboard’s central row

Find a comfortable escape stroke
You can bind another keystroke for escape to come back to normal mode, I use jj for that. You do so by adding the following to your .vimrc file

imap jj <Esc>

Pimp your history
You can set a larger history for the undo u action adding

set undolevels=10000

Motions

After these setups, here is the handiest motion that I mostly use while coding:

Change, delete, select in
You can change, delete or select something inside i almost everything, for example, if you wish to change the parameters of this function

fun someFunction(someParam: String)

you can simply move your cursor inside the parenthesis and, in normal mode, hit ci( di( or vi( to change, delete or enter visual mode with selection inside the parenthesis. Similar you can delete, change or select a word with ciw diw and viw . This work for double quote " , single quote ' , square brackets [ and so on.

Change, delete, select until a character
Similar to the motion to select inside, you can select until with ct( , dt( and vt( wich will change, delete or select in visual mode until the specified character is found (in the example before until an open parenthesis is found)
Similar it’s possible to move to a certain character with f( (move to first open parentheses).

Surround in quote or brace
Unfortunately, the default behaviour of the IDE to wraps things that are highlighted with a quote or brace does not work.
There is a solution to that: you can edit your .ideavimrc file adding:

set surround

Now in an IntelliJ ide, you can enter visual mode with v to select the text you want to surround with and then hit S" or S{ or whatever your need is.

And that’s almost everything I wish I knew when I started!
Thanks for reading!

--

--