Loading ...
Sorry, an error occurred while loading the content.

Re: bracket completion

Expand Messages
  • Fritz Mehner
    ... In addition I use the following settings vnoremap ( s() P vnoremap [ s[] P vnoremap { s{} P to surround a selection
    Message 1 of 33 , Apr 1, 2007
    • 0 Attachment
      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
    • Winfred Lu
      ... It is very useful, thank you.
      Message 33 of 33 , Apr 4, 2007
      • 0 Attachment
        2007/4/3, Charles E Campbell Jr <drchip@...>:
        > Here's one: http://vim.sourceforge.net/scripts/script.php?script_id=1269
        It is very useful, thank you.
      Your message has been successfully submitted and would be delivered to recipients shortly.