开发者

Vim: Indent current (blank) line and insert

开发者 https://www.devze.com 2023-01-16 19:06 出处:网络
Say I have the current text in the buffer, where _ marks the cursor int main(int argc, char **argv) { printf(\"Hello, world!\\n\");

Say I have the current text in the buffer, where _ marks the cursor

int main(int argc, char **argv) {
    printf("Hello, world!\n");

_
}

I have indentexpr on (though a solution with cindent or autoindent will probably work, too).

How do I begin inserting 开发者_如何学运维so my cursor is placed at the appropriate column to follow the indention rules, i.e.:

int main(int argc, char **argv) {
    printf("Hello, world!\n");

    _
}

Currently I find myself using ddO often (or ddo at the end of the buffer), but it seems there should be a better way. Using == or even >> or v> do not seem to work because the line is blank.


Try going back into normal mode and typing S


If I'm on a blank line, but at the wrong insertion point, I tend to use CTRL-f (while in insert mode) to indent to the correct place.

This is useful when I've hit ESC to get out of insert mode, and I've then lost the proper indentation. Hitting i followed by CTRL-f does the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消