Skip to content

Instantly share code, notes, and snippets.

@lo48576
Last active January 27, 2016 06:31
Show Gist options
  • Select an option

  • Save lo48576/abb65f85860d05a8bd9c to your computer and use it in GitHub Desktop.

Select an option

Save lo48576/abb65f85860d05a8bd9c to your computer and use it in GitHub Desktop.
ignore input for duplicate closing paren/brace/brackets.
function! InsDedupParen(closer)
let cur_ch = getline('.')[col('.')-1]
let parenRList = ["}", ")", "]", "\"", "\'"]
let paren_index = index(parenRList, cur_ch)
if paren_index >= 0 && parenRList[paren_index] == a:closer
return "\<C-O>a"
endif
return a:closer
endfunction
inoremap <silent> ) <C-R>=InsDedupParen(')')<CR>
inoremap <silent> ] <C-R>=InsDedupParen(']')<CR>
inoremap <silent> } <C-R>=InsDedupParen('}')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment