Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function! MissBracket(char)
- if a:char == getline('.')[col('.')-1]
- return "\<Right>"
- endif
- return a:char
- endfunction
- function! NewLineWithIndent(open_br, close_br)
- if a:close_br == getline('.')[col('.')-1] && a:open_br == getline('.')[col('.')-2]
- return "\<CR>\<ESC>O"
- endif
- return "\<CR>"
- endfunction
- if exists("g:brackets") && g:brackets == 1
- inoremap ( ()<LEFT>
- inoremap <expr> ) MissBracket(')')
- endif
- if exists("g:braces") && g:braces == 1
- inoremap { {}<LEFT>
- inoremap <expr> } MissBracket('}')
- inoremap <expr> <CR> NewLineWithIndent('{', '}')
- endif
- if exists("g:square_brackets") && g:square_brackets == 1
- inoremap [ []<LEFT>
- inoremap <expr> ] MissBracket(']')
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement