Vimrc settings to emulate Sublime's parenthesi

2019-02-25 16:19发布

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 {}.

2条回答
来,给爷笑一个
2楼-- · 2019-02-25 16:31

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.

查看更多
\"骚年 ilove
3楼-- · 2019-02-25 16:51

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)
查看更多
登录 后发表回答