Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function! MissBracket(char)
  2. if a:char == getline('.')[col('.')-1]
  3. return "\<Right>"
  4. endif
  5. return a:char
  6. endfunction
  7.  
  8. function! NewLineWithIndent(open_br, close_br)
  9. if a:close_br == getline('.')[col('.')-1] && a:open_br == getline('.')[col('.')-2]
  10. return "\<CR>\<ESC>O"
  11. endif
  12. return "\<CR>"
  13. endfunction
  14.  
  15. if exists("g:brackets") && g:brackets == 1
  16. inoremap ( ()<LEFT>
  17. inoremap <expr> ) MissBracket(')')
  18. endif
  19.  
  20. if exists("g:braces") && g:braces == 1
  21. inoremap { {}<LEFT>
  22. inoremap <expr> } MissBracket('}')
  23. inoremap <expr> <CR> NewLineWithIndent('{', '}')
  24. endif
  25.  
  26. if exists("g:square_brackets") && g:square_brackets == 1
  27. inoremap [ []<LEFT>
  28. inoremap <expr> ] MissBracket(']')
  29. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement