A.J.Mechelynck schrieb:

Greg Fitzgerald wrote:

Anyone know of a way to achieve bracket completion? For example if your typing a if statement, if (something) { once you type the first bracket
the 2nd one is inserted below for you. Scribes and a few other editors
have this functionality and was hoping to achieve it with Vim. Another
thing that this does, if you were to type $data[' for example. The 2nd '
would be inserted for you after your cursor. Just seems to save time
when I played with scribes a few days ago. I was looking through the
help, scripts and mailing list archives for something like this but have
not hit any matches. Just wondering if people have ideas on how this
could be done or maybe know of an existing way. Thanks in advance.

--Greg


    :inoremap { {<CR>}<Up><End>
    :inoremap [ []<Left>
    :inoremap ( ()<Left>

etc.

This assumes brace indenting is taken care of (by 'cindent' or 'indentexpr').

IIUC, you can still enter an "unpaired brace" (or bracket or paren) by prefixing it with Ctrl-V (or with Ctrl-Q if Ctrl-V pastes).

Best regards,
Tony.

In addition I use the following settings

vnoremap  (  s()<Esc>P<Right>
vnoremap  [  s[]<Esc>P<Right>
vnoremap  {  s{}<Esc>P<Right>

to surround a  selection in visual mode.
Regards,
Fritz




Reply via email to