How do I emulate Sublime text's auto complete behavior for curly braces {}
on vim? Basically, when a parenthesis is opened, it should auto close in the same line, and when <CR>
is pressed the cursor should go to the next line with a block indentation and }
should fall in line with the original indention of the line containing the {
. If my question is not clear, this is the default behavior of most code editors when dealing with {}
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The Automatically append closing characters page on the Vim Tips Wiki has everything from simplistic mappings to complete plugin solutions. There seem to be issues with the latest Vim 7.4 version, though.
回答2:
There exist many plugins with similar features as Ingo pointed out.
lh-brackets, that I'm maintaining, has the features you describe:
{
inserts{}
and moves the cursor in between (and also inserts a placeholder after the closing bracket- hitting
<cr>
while within a pair of curly-brackets will insert another newline in-between (and indent correctly)