search

Home  >  Q&A  >  body text

vim - Why does the editor have the "bracket completion" function?

Normally input the right bracket, you need shift + right bracket , two keystrokes, but your hand will not leave the main keyboard area;
Use brackets to complete. After completing the content input, you need to press the direction key. Although you only hit the key once, your right hand leaves the main keyboard area and the displacement is large.
Therefore, I feel that this function is not very practical, so what is its main value?

Update:
When I asked this question, I had not found an excellent implementation of bracket matching in vim, and it was super difficult to use. Now I have found a piece of code, the effect is the same as in ST2. If you are interested, please go to: Automatic completion of brackets in vim

天蓬老师天蓬老师2743 days ago657

reply all(7)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 16:42:41

    Well, first of all, I think there are two advantages to doing this
    1) It will automatically add right brackets to prevent you from forgetting to write
    2) After you enter the left bracket, the cursor will be between the two brackets. At this time, you can write a certain amount of code and then you can directly enter the right bracket to get out of the brackets. This kind of feeling is obviously much better than the logical feeling of entering brackets first and then writing code

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 16:42:41

    The main reason is that I am afraid that the left and right brackets will not match. Problems such as saving fingers are not the most important thing.

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 16:42:41

    So many editors have the function of automatically completing brackets and automatically moving the cursor into the brackets!

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 16:42:41

    Enter a ()?
    What proportion of a function without parameters and an empty tuple can be used in a real project?
    Most of the time (params)
    There is also a shortcut key called jump to outside the brackets

    reply
    0
  • 黄舟

    黄舟2017-05-16 16:42:41

    There is no bracket completion, the author writes a Lisp code to see ~~

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 16:42:41

    Development efficiency depends more on specifications than on keystroke speed.

    reply
    0
  • 阿神

    阿神2017-05-16 16:42:41

    To put it simply, whether it is a computer language or a human language, brackets are always used in pairs. Therefore, many editors naturally provide bracket completion.

    I have never encountered the problem of hands leaving the main keyboard area when using Xcode: you can use Tab to automatically accept completion brackets, or you can directly type a semicolon to accept completion of an entire line.

    reply
    0
  • Cancelreply