Quickest way to change a pair of parenthesis to brackets in vim

后端 未结 6 1143
野的像风
野的像风 2020-12-30 02:00

I am new to vim and in the process of discovering tons of interesting things that one can using this powerful editor.

One particular thing that I need to do very fr

6条回答
  •  情深已故
    2020-12-30 02:43

    I personally use https://github.com/tpope/vim-surround as it provides everything I could ever need, reading through the source you can see the solution is non-trivial.

    A typical example:

    Hello("World")
    

    with the cursor somewhere between the (), you can type cs([ in normal mode to get:

    Hello["World"]
    

    surround.vim is easily installed with either Pathogen or Vundle, personally I prefer vundle. https://github.com/VundleVim/Vundle.vim

    adding the important commented point:

    cs([ adds spaces in the block, this should be cs)]
    

提交回复
热议问题