Vim 智能插入分号 [英] Vim smart insert semicolon
本文介绍了Vim 智能插入分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个 Vim 插件可以处理智能分号插入,就像 Eclipse 中的插件一样?
Is there a Vim plugin that can handle smart semicolon insertion, like the one in Eclipse?
示例(管道字符是插入光标):
Example (pipe character is insertion cursor):
foobar(|)
我输入一个分号:
foobar();|
同样:
foobar("blah|")
我输入一个分号:
foobar("blah");|
如果我想在原来的光标位置加一个分号,我在智能重新定位后按退格键:
If I want a semicolon at the original cursor position, I press backspace after the smart re-position:
foobar("hello|")
foobar("hello");|
foobar("hello;|")
推荐答案
我使用这个映射:
inoremap <leader>; <C-o>A;
它不是 ;
因为我经常使用分号并且在不止一种情况下使用.
It's not ;
because I use semicolons often and in more than one context.
用于输入单个普通模式命令.A;
表示在行尾添加一个;
".
<C-o>
is used to input a single normal mode command.A;
means "add a;
at the end of the line".
这篇关于Vim 智能插入分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文