editor - How to insert matching brace in vim MANUALLY? -


there text in buffer

[{(lorem) ipsum <cursor here> 

how can insert closing brace }, type something, , insert ] matching opening braces { , [

let me explain why need this.

for example have type pure javascript code (because coffee machine out of order @ moment)

$(document).ready(function(){   var classa = (function(){      function classa(){}      <100 lines of code here>      return classa;   -->oh, closing brace should insert here....! 

another case

[thewebview loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:[nsstring stringwithformat:@"%@/%@", hostname, @"some/path/here"]] -> huh, next? how many closing braces missing? 

and why clarify manually in question title. because there are some key bindings to automatically insert closing braces. example in ( ()<left>. however, want insert closing brace when need.

i know there i_<c-x>_<c-o> insert closing xml tag. don't know how deal these ones.

thank in advance.

finally, come vim-close-pair plugin.

just type <ctrl-l> (insert mode), find , insert missing brace automatically.

  • install vundle:

    • append plugin 'nissasssin17/vim-close-pair .vimrc file
    • restart vim or run :source ~/.vimrc
    • run :plugininstall
  • manual install:

    git checkout https://github.com/nissassin17/vim-close-pair.git cd vim-close-pair mkdir -p ~/.vim/plugin cp -f plugin/close-pair.vim ~/.vim/plugin/ mkdir -p ~/.vim/autoload cp -f autoload/close-pair.vim ~/.vim/autoload/ 

Comments