Vim:缩进当前(空白)行并插入 [英] Vim: Indent current (blank) line and insert

查看:250
本文介绍了Vim:缩进当前(空白)行并插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我在缓冲区中有当前文本,其中_标记光标

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

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

_
}

我打开了indentexpr(尽管使用cindentautoindent的解决方案也可能会起作用).

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");

    _
}

目前,我发现自己经常使用ddO(或在缓冲区末尾使用ddo),但是似乎应该有更好的方法.使用==甚至>>v>似乎都不起作用,因为该行是空白的.

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.

推荐答案

尝试返回普通模式并键入S

Try going back into normal mode and typing S

这篇关于Vim:缩进当前(空白)行并插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆