Insert mode edit mappings


A common trait among Vim power-users is that they aim to enter and exit insert mode as little as possible. They use normal-mode navigation and make judicious use of the dot command to repeat, improving edit efficiency. Of course, insert mode is essential for actual insertion and once you’re in it, you should know about a number of mappings that will help you stay in insert mode. By staying in insert mode and completing your entire edit without exiting, you can build up edits that are repeatable.

Here are several mappings that work while insert mode. Perhaps some of these might be new to you, or at least helpful for reinforcement:

  • ctrl-h – Delete previous character (same as backspace)
  • ctrl-w – Delete previous word
  • ctrl-u – Delete entire line (except any indent)
  • ctrl-t – Indent the current line
  • ctrl-d – Backdent the current line

There’s a brief screencast of each of these below. Note the particular utility of indenting or backdenting the current line while already in insert mode. If you’re trying to build a repeatable command that inserts text and indents it, ctrl-t will do the trick.

How useful was this tip?

Average rating 4.8 / 5. Vote count: 75

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts