search

Home  >  Q&A  >  body text

Problems with indentation of curly braces in vim

Now assume that you write an if statement. After typing the left brace and pressing Enter, it looks like this (auto-completion is set)

if(a < b) {
}

The effect I want is after pressing Enter
if(a < b) {
I//The cursor is here
}

How should you set up vimrc like this?
Thanks!

仅有的幸福仅有的幸福2776 days ago687

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:41:40

    The vim command is too complicated, we recommend SUB

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 16:41:40

    This can be accomplished with abbreviations:

    :iabbrev {i {}<esc>i<cr>O

    1. {i Feel free to change
    2. O will be indented according to the current indent setting
    3. If you are not satisfied with the current effect, you can adjust it according to the document

    reply
    0
  • Cancelreply