vim

VIM: How to move cursor in empty lines?


I've been through a lot of instructions, but I can't find a solution to this problem. Giving this code in vim as an example:

#include <iostream>

 <--- My cursor is here

int main(){
std::cout << "Hello world";
return 0;
}

My cursor is stuck in the position above (I can't press h or k). So I want to be able to press h and k (moving my cursor forward and backward in an empty line), what could I do to allow this?

Thank you so much for reading all this.


Solution

  • Perhaps you want:

    :set virtualedit=all
    

    Read the documentation for details on the other options available:

    :help virtualedit
    

    From the docs: "Virtual editing means that the cursor can be positioned where there is no actual character."