Vim motions without exiting the Insert Mode

Franco Pasut
2 min readOct 17, 2020

--

Est modus in rebus

Every vimmers knows what’s a modal writing system. In Vim there’s a mode for everything: Normal, Insert, Command, Visual, etc. In ancient Rome you would have said: Est modus in rebus.

When you write you are in the Insert mode and to give motion commands you should change to the Normal mode.

However sametimes I do prefer to move around a document that I’m editing without exiting the Insert mode. I feel that sometimes it is faster.

Here are few personal notes that some people might find useful.

Vim’s philosophy: absolute efficiency

Suppose you are typing some text and, therefore, you are in the Insert mode. If you need a one shot switch in the Normal mode you can type Ctrl-o followed by a Normal command.

For instance: by typing Ctrl-o 3w while in Insert mode you move three words forward and you can continue writing.

The canonical sequence while in the Insert mode, instead, is: Esc (or Ctrl-c or Ctrl-[) 3w i.

Two commands instead of three: a 33% gain. Perfectly in accordance with Vim’s absolute efficiency philosophy.

By the way: if you need to go the beginning of the line keeping the Insert mode you can use either Ctrl-o 0or Ctrl-o I and if need to go the end of the line Ctrl-o $ or Ctrl-o A.

Jumping in Insert Mode

The same Ctrl-o prefix can be very useful in combination with vim-easymotion plugin.

You can jump using easymotion combinations and and maintain the Insert mode.

For example:

  • Type Ctrl-o \f a to jump to every “a” letter
  • Type Ctrl-o \s ab to jump to every “ab” letters
  • Type Ctrl-o \w to jump to the beginning of every word
  • Type Ctrl-o \l to jump to the beginning of every line

A very simple shortcut

A very simple shortcut in Insert mode that sometimes you do not find in Vim cheat sheets is the following one: Ctrl-w.

While in Insert mode, you must type Ctrl-w to delete the previous word without leaving the Insert mode itself.

But aren’t there also arrow keys?

Some people might say: what about the arrow keys?

You could also use, with a little of configuration, the arrow keys and other movement keys of your operating system (i.e. Home, End, PgUp, PgDown), but the real vimmer should never move his hands from the editing position.

I agree with you!… but sometimes I use them too.

Thank You for your attention.

--

--

Franco Pasut
Franco Pasut

Written by Franco Pasut

I am a lawyer and occasionally write about technology.

No responses yet