I have this binding in my .vimrc
to trick autointent into actually populating the next line with real characters, so that if I hit enter, leave the line, and click back to it, I can already be at the indentation level of the surrounding code.
"Make autoindent insert actual characters instead of fake characters that go
"away if you move.
inoremap <CR> <CR><space><BS>
However, this leaves lines with trailing whitespace (enough spaces to indent to the level of the surrounding code), like this:
int.main().{
....int.a;
....
....int b;
}
This lets me click on that blank line, hit i
, start typing, and get code at the right indentation level.
Now I'm working on a project where the linter has a Strong Opinion that there should be no trailing spaces, even on blank lines that are, semantically, blank at a particular indentation level.
Can I keep the behavior of being able to click on the tail end of a line and have my cursor be at the right position to insert code on that line, but not fill the file with real trailing spaces? Is there a good way to bind i
to automatically jump to the right indentation level when entering insert mode? Or is there another existing keybinding I should be using for "enter insert mode at the indentation level of surrounding code"?