I'm new to Vim, and I've read that a best practice in Vim is to begin a new Append with each line. In other words, instead of pressing <Enter>, it is more advisable to leave Insert mode, and begin a new line with o.

While I can easily do this with <Esc>-o, I'm wondering if it's easier to set my <Enter> key to that keybinding. Is that possible to do while in Insert mode?

  • 3
    Where did you hear that "best practice"? I can't think of any reason for doing things like that. It's kind of insane, to be honest. Depending on what kind of text you're entering you might want to set up auto-wrapping in which case you don't have to press Enter AND you don't have to leave Insert mode. Otherwise, just hit Enter.
    – B Layer
    Jul 29, 2021 at 1:00
  • 1
    The idea is to use o/O rather than A enter when youre already in normal mode. In insert mode theres no reason to do this unless you’re trying to break up undo history
    – D. Ben Knoble
    Jul 29, 2021 at 12:28
  • 1
    @D.BenKnoble Breaking up undo history is precisely the reason I heard for doing it--you can more easily "version control" your inserts.
    – Yehuda
    Jul 29, 2021 at 21:02
  • @Yehuda Well thank goodness someone has at least provided a remotely plausible explanation. (Not that I don't still think it's pretty insane and it is most certainly not a "best practice".) :) If one wants to occasionally hit <Esc>i for that purpose ... okay, I guess ... but doing it every line just sounds terribly inefficient/inconvenient to me.
    – B Layer
    Jul 31, 2021 at 0:15
  • BTW, one thing that can be considered a best practice is to always be in Normal mode if you're not entering text/content (e.g. if you stop even for a couple seconds to think. I happen to do this myself.) Unless you tend to type continuously for long stretches this usually takes care of the "undo resetting" we're talking about.
    – B Layer
    Jul 31, 2021 at 0:22

1 Answer 1


To my knowledge nobody says this is "best practice," and I would advise against it.

If you really want to do this, though, try this mapping:

:inoremap <CR> <Esc>o

There's a wealth of information in ":help map.txt" that could help you understand how to map in various modes, but briefly this sets a mapping in insert mode, doesn't let the mapping recurse, and uses <> key notation (see ":help key-notation").

  • Thanks for the answer. After reading the comments posted to the question, I'm not sure about doing it, honestly - I'm curious to hear why you would recommend against it, as well.
    – Yehuda
    Jul 29, 2021 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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