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

Snippet for adding closing parentheses in ultisnips

Expand Messages
  • Marco
    Hi! I have the following definition in my .vimrc to easily type parentheses. inoremap ( ( =UltiSnips_Anon( ($1)$0 , ( ) This snippet does the
    Message 1 of 7 , Nov 4, 2012
    • 0 Attachment
      Hi!

      I have the following definition in my .vimrc to easily type
      parentheses.

      inoremap ( (<C-R>=UltiSnips_Anon('($1)$0', '(')<CR>

      This snippet does the following: Whenever I type an open parentheses
      it adds a closing one and positions the cursor in between. With
      <Ctrl-j> I can jump after the closing parentheses. This, however,
      works only if I place a space between the function and the open
      parentheses.

      main () // works, the closing parentheses is added
      main( // fails without space

      A simple check with

      inoremap ( ()

      shows that the mapping is triggered with and without space, so the
      problem is the snippet, not the mapping.

      How can I fix the snippet to work with and without space after
      the function name? Or is there a better way to achieve that?


      Marco


      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Chris Lott
      ... Unless I am misunderstanding, you could use delimitmate [http://clinki.es/go/Pf] which does the completions and puts the cursor inside...plus when you get
      Message 2 of 7 , Nov 4, 2012
      • 0 Attachment
        On Sun, Nov 4, 2012 at 9:10 AM, Marco <netuse@...> wrote:
        >
        > How can I fix the snippet to work with and without space after
        > the function name? Or is there a better way to achieve that?

        Unless I am misunderstanding, you could use delimitmate
        [http://clinki.es/go/Pf%5d which does the completions and puts the
        cursor inside...plus when you get to the end you just type the closing
        character and it jumps over that closing character. Much easier than
        CTRL-J for me.

        c
        --
        Chris Lott <chris@...>

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Marco
        ... I just installed it and it seems to work. Thanks for the tip. ... The only thing that bothers me is that the default key combination to jump over
        Message 3 of 7 , Nov 4, 2012
        • 0 Attachment
          2012-11-04 Chris Lott:

          > On Sun, Nov 4, 2012 at 9:10 AM, Marco <netuse@...> wrote:
          > >
          > > How can I fix the snippet to work with and without space after
          > > the function name? Or is there a better way to achieve that?
          >
          > Unless I am misunderstanding, you could use delimitmate
          > [http://clinki.es/go/Pf%5d which does the completions and puts the
          > cursor inside

          I just installed it and it seems to work. Thanks for the tip.

          > ...plus when you get to the end you just type the closing
          > character and it jumps over that closing character. Much easier
          > than CTRL-J for me.

          The only thing that bothers me is that the default key combination
          to jump over delimiters is <S-Tab>. I'd like to map it <Ctrl-j>.
          Then it works in a consistent fashion with the other jumps. How can
          I achieve that?

          As you mention, typing the closing character is also possible. This
          is not feasible in my opinion. You have to type the open character,
          the text in between and then the closing one. What do you need the
          plugin for? And the closing characters are sometimes, e.g. ) much
          harder to reach than <Ctrl-j> which completely lies on the homerow.


          Marco


          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Chris Lott
          ... I can t help you there... ... I find reaching for the CTRL-j to be more of a pain than almost any punctuation! But either way it s a single keystroke and I
          Message 4 of 7 , Nov 4, 2012
          • 0 Attachment
            On Sun, Nov 4, 2012 at 10:08 AM, Marco <netuse@...> wrote:
            > 2012-11-04 Chris Lott:
            >
            >
            > The only thing that bothers me is that the default key combination
            > to jump over delimiters is <S-Tab>. I'd like to map it <Ctrl-j>.
            > Then it works in a consistent fashion with the other jumps. How can
            > I achieve that?

            I can't help you there...

            > As you mention, typing the closing character is also possible. This
            > is not feasible in my opinion. You have to type the open character,
            > the text in between and then the closing one. What do you need the
            > plugin for? And the closing characters are sometimes, e.g. ) much
            > harder to reach than <Ctrl-j> which completely lies on the homerow.

            I find reaching for the CTRL-j to be more of a pain than almost any
            punctuation! But either way it's a single keystroke and I see the
            utility of any of these methods as much for proper balance as for
            easing the placement of a second character.

            c
            --
            Chris Lott <chris@...>

            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • SirVer
            snippet ( Brackets i (${VISUAL}$1) endsnippet The option is inword expansion. I wish people would read the docs before asking on the internet. ... -- You
            Message 5 of 7 , Nov 21, 2012
            • 0 Attachment
              snippet ( "Brackets" i
              (${VISUAL}$1)
              endsnippet

              The option is inword expansion. I wish people would read the docs before asking on the internet.

              On Sunday, November 4, 2012 8:34:31 PM UTC+1, Chris Lott wrote:
              > On Sun, Nov 4, 2012 at 10:08 AM, Marco <netuse@...> wrote:
              >
              > > 2012-11-04 Chris Lott:
              >
              > >
              >
              > >
              >
              > > The only thing that bothers me is that the default key combination
              >
              > > to jump over delimiters is <S-Tab>. I'd like to map it <Ctrl-j>.
              >
              > > Then it works in a consistent fashion with the other jumps. How can
              >
              > > I achieve that?
              >
              >
              >
              > I can't help you there...
              >
              >
              >
              > > As you mention, typing the closing character is also possible. This
              >
              > > is not feasible in my opinion. You have to type the open character,
              >
              > > the text in between and then the closing one. What do you need the
              >
              > > plugin for? And the closing characters are sometimes, e.g. ) much
              >
              > > harder to reach than <Ctrl-j> which completely lies on the homerow.
              >
              >
              >
              > I find reaching for the CTRL-j to be more of a pain than almost any
              >
              > punctuation! But either way it's a single keystroke and I see the
              >
              > utility of any of these methods as much for proper balance as for
              >
              > easing the placement of a second character.
              >
              >
              >
              > c
              >
              > --
              >
              > Chris Lott <chris@...>

              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            • Marco
              ... This basically works. But the expansion has to be triggered with . The code from my original posting does not need to be expanded with , the
              Message 6 of 7 , Nov 21, 2012
              • 0 Attachment
                2012-11-21 SirVer:

                > snippet ( "Brackets" i
                > (${VISUAL}$1)
                > endsnippet

                This basically works. But the expansion has to be triggered with
                <Tab>. The code from my original posting does not need to be
                expanded with <Tab>, the closing brace is added automatically when
                the open brace is typed.

                > I wish people would read the docs before asking on the internet.

                I don't think that comment was necessary.


                Marco


                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
              • Christian Brabandt
                ... And I wish, people would read the signature, that is shown at the bottom of each message here... SCNR, Christian -- You received this message from the
                Message 7 of 7 , Nov 22, 2012
                • 0 Attachment
                  On Wed, November 21, 2012 17:51, SirVer wrote:
                  > I wish people would read the docs before asking on the internet.

                  And I wish, people would read the signature, that is shown at the bottom
                  of each message here...

                  SCNR,
                  Christian

                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php
                Your message has been successfully submitted and would be delivered to recipients shortly.