When I enter insert mode using o or O when programming, the cursor appears at the correct level of indentation. In this example below, X is the place where I press o and Y is where my cursor appears.

func doX() error{X

But if I'd do this

func doX() error{

Now where I press X is also where my cursor appears. What I want is:

func doX() error{
X    Y

Hopefully this makes sense!

o/O enter newlines whilst i just goes to insert mode, I expect that to be the 'problem' but I'm wondering if this can be fixed? I don't want i to enter a new line, just to start editting at the right indentation point. (If the line is empty).

Preferably another key than i :)


  • Your question is good, it was only asked before :-) But don't worry, your contributions are still welcomed.
    – peterh
    May 31, 2019 at 15:28
  • But that question is about when you are already in insert mode :O mine is to jump to insert mode at the correct level of indentation :) Jun 1, 2019 at 16:06


Browse other questions tagged or ask your own question.