Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic closing brackets for Vim [closed]

Is there any WORKING plugin for Vim 7.4 that would automatically close brackets ('{}', '[]', '()') and maybe insert some carriage returns (for '{}' at least)?

I know this question has been asked quite a few times but none of the answers either do not seem to work in vim 7.4 or the plugin has not been updated or something.

So far I've tried vim-smartinput, autoclose and delimitmate and NONE of these have managed to insert any closing characters even though I have enabled the plugins and they otherwise seem to be active. I don't know if there has been some changes in vim that somehow breaks these plugins. None of these plugins seem to be updated in a ~year at least. Any working solutions that would work with vim 7.4?

like image 710
Dago Avatar asked Jan 23 '14 18:01

Dago


People also ask

How do I automatically close brackets in vim?

This autocomplete in insert mode, provided set paste is not set. Keep it in the vimrc to avoid typing it every time and when we don't want the mapping, we need to escape it using ctrl + v before typing the mapped char like ( { etc.

How do you close a bracket in Python?

According to the PEP 8 standard, there are two ways to line up the closing braces, brackets, or parentheses. First, line it up with the first non-whitespace character of the previous line. Second, line it up with the first character that starts the multi-line construct.


1 Answers

For those of us, who want a vanilla vim:

inoremap " ""<left> inoremap ' ''<left> inoremap ( ()<left> inoremap [ []<left> inoremap { {}<left> inoremap {<CR> {<CR>}<ESC>O inoremap {;<CR> {<CR>};<ESC>O 

This autocomplete in insert mode, provided set paste is not set. Keep it in the vimrc to avoid typing it every time and when we don't want the mapping, we need to escape it using ctrl + v before typing the mapped char like ( { etc.

like image 52
dlmeetei Avatar answered Sep 19 '22 16:09

dlmeetei