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

evaluating vim functions in search mappings

Expand Messages
  • Charles Smith
    In order to be able to go to the next command in python, I d like to have a mapping as follows, but I can t get it to work: map ]0 /^ s {0,^R=wincol()} S^M I m
    Message 1 of 13 , May 12 3:08 AM
    • 0 Attachment
      In order to be able to go to the next command in python, I'd like to
      have a mapping as follows, but I can't get it to work:

      map ]0 /^\s\{0,^R=wincol()}\S^M

      I'm not getting the evaluation correct. Can someone help?

      ----------------------------------------------------------------------------------
      http://www.creative-telcom-solutions.de

      --
      --
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Marc Weber
      ... Can you retry telling us what you mean by next command ? Plugins like ttoc may be close. Usually using / ? searches are fastest for navigation. (eg /r n
      Message 2 of 13 , May 12 3:14 PM
      • 0 Attachment
        Excerpts from Charles Smith's message of Sun May 12 12:08:15 +0200 2013:
        > In order to be able to go to the next command in python, I'd like to
        > have a mapping as follows, but I can't get it to work:
        >
        > map ]0 /^\s\{0,^R=wincol()}\S^M

        Can you retry telling us what you mean by "next command"?

        Plugins like ttoc may be close.

        Usually using / ? searches are fastest for navigation. (eg /r n to jump
        to "for navigation")

        Marc Weber

        --
        --
        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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Charles Smith
        ... Python delineates scope merely with indentation. I mean the next command in the same scope. So, given the python snippet (this is, btw, no endorsement of
        Message 3 of 13 , May 13 12:20 AM
        • 0 Attachment
          On May 13, 12:14 am, Marc Weber <marco-owe...@...> wrote:
          > Excerpts from Charles Smith's message of Sun May 12 12:08:15 +0200 2013:
          >
          > > In order to be able to go to the next command in python, I'd like to
          > > have a mapping as follows, but I can't get it to work:
          >
          > >   map ]0 /^\s\{0,^R=wincol()}\S^M
          >
          > Can you retry telling us what you mean by "next command"?


          Python delineates scope merely with indentation. I mean the next
          command in the same scope. So, given the python snippet (this is,
          btw, no endorsement of python):

          for i in f():

          print i

          print "done"

          exit

          if my cursor is on the first line (e.g. on the first char of the first
          line), I want to be able to skip to print (or to exit if there were no
          print)



          So, I want to look for the next line that has as much white space at
          the beginning as the line where the cursor currently is - or has less
          white space, meaning that the section is over.

          The strategy is to use \{0,x}, where x is the builtin-function
          wincol(). I'm trying to use the ^R= evaluation operation but vim
          complains with:

          E554: Syntax error in \{...}




          > Plugins like ttoc may be close.
          >
          > Usually using / ? searches are fastest for navigation. (eg /r n to jump
          > to "for navigation")
          >
          > Marc Weber

          --
          --
          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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Charles Smith
          Basically, my intent is to make up for the lack of brace-delineated blocks - in C or perl, I could just put my cursor on the opening brace, hit % and be at the
          Message 4 of 13 , May 13 2:36 AM
          • 0 Attachment
            Basically, my intent is to make up for the lack of brace-delineated
            blocks - in C or perl, I could just put my cursor on the opening
            brace, hit % and be at the end. Since I have no braces in python,
            this is a poor-man's version of that.


            On May 13, 9:20 am, Charles Smith <cts.private.ya...@...> wrote:
            > On May 13, 12:14 am, Marc Weber <marco-owe...@...> wrote:
            >
            > > Excerpts from Charles Smith's message of Sun May 12 12:08:15 +0200 2013:
            >
            > > > In order to be able to go to the next command in python, I'd like to
            > > > have a mapping as follows, but I can't get it to work:
            >
            > > >   map ]0 /^\s\{0,^R=wincol()}\S^M
            >
            > > Can you retry telling us what you mean by "next command"?
            >
            > Python delineates scope merely with indentation.  I mean the next
            > command in the same scope.  So, given the python snippet (this is,
            > btw, no endorsement of python):
            >
            >     for i in f():
            >
            >         print i
            >
            >     print "done"
            >
            > exit
            >
            > if my cursor is on the first line (e.g. on the first char of the first
            > line), I want to be able to skip to print (or to exit if there were no
            > print)
            >
            > So, I want to look for the next line that has as much white space at
            > the beginning as the line where the cursor currently is - or has less
            > white space, meaning that the section is over.
            >
            > The strategy is to use \{0,x}, where x is the builtin-function
            > wincol().  I'm trying to use the ^R= evaluation operation but vim
            > complains with:
            >
            >   E554: Syntax error in \{...}
            >
            >
            >
            >
            >
            >
            >
            > > Plugins like ttoc may be close.
            >
            > > Usually using / ? searches are fastest for navigation. (eg /r n to jump
            > > to "for navigation")
            >
            > > Marc Weber

            --
            --
            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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Marc Weber
            ... returns indentation of current line. Thus ... or such might do it. A second solution would be using folding. In the end - you should try using better
            Message 5 of 13 , May 13 3:03 AM
            • 0 Attachment
              :h indent()
              returns indentation of current line.
              Thus

              :map <X> /^<c-r>=repeat(' ', indent(line('.')))<cr>\S<cr>
              or such might do it.

              A second solution would be using folding.

              In the end - you should try using better search terms.

              Eg googling for "indendation based movement vim"
              http://stackoverflow.com/questions/896145/more-efficient-movements-editing-python-files-in-vim
              http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indentation
              http://vim.wikia.com/wiki/Indenting_source_code
              [...]

              I didn't read them, but they might be helpful.

              Try to rethink about the way you're looking for information.

              Marc Weber

              --
              --
              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

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Charles Smith
              Thanks Marc. ... =repeat( , indent(line( . ))) S E15: Invalid expression: repeat( , indent(line( . ))) S and using the original mapping, modified to use
              Message 6 of 13 , May 13 3:37 AM
              • 0 Attachment
                Thanks Marc.

                Unfortunately, I couldn't get your suggestion to work:

                :map ]0 /^^R=repeat(' ', indent(line('.')))\S

                =repeat(' ', indent(line('.')))\S
                E15: Invalid expression: repeat(' ', indent(line('.')))\S

                and using the original mapping, modified to use the indent() function

                :map ]0 /^\s\{0,^R=indent(line('.'))}\S

                =indent(line('.'))}\S
                E15: Invalid expression: indent(line('.'))}\S




                On May 13, 12:03 pm, Marc Weber <marco-owe...@...> wrote:
                > :h indent()
                > returns indentation of current line.
                > Thus
                >
                > :map <X> /^<c-r>=repeat(' ', indent(line('.')))<cr>\S<cr>
                > or such might do it.
                >
                > A second solution would be using folding.
                >
                > In the end - you should try using better search terms.
                >
                > Eg googling for "indendation based movement vim"http://stackoverflow.com/questions/896145/more-efficient-movements-ed...http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indent...http://vim.wikia.com/wiki/Indenting_source_code
                > [...]
                >
                > I didn't read them, but they might be helpful.
                >
                > Try to rethink about the way you're looking for information.
                >
                > Marc Weber

                --
                --
                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

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Marc Weber
                Reread my message. I told you many ways to reach your goal. One was clear: http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indentation I didn t
                Message 7 of 13 , May 13 3:46 AM
                • 0 Attachment
                  Reread my message. I told you many ways to reach your goal.
                  One was clear:
                  http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indentation

                  I didn't test my mapping, yes - you may have to understand the pieces to
                  make it work - so if you have trouble understanding the pieces ask
                  specific questions.

                  Thus a great reply would have been
                  - I didn't understand your sample, I don't know what <c-r> means
                  - the links you provide didn't help me because ...

                  I don't have time to repeat myself.

                  Marc Weber

                  --
                  --
                  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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Charles Smith
                  Right, Marc, I see you re a busy man. Hopefully somebody else will feel intrigued by the problem and jump in. ... -- -- You received this message from the
                  Message 8 of 13 , May 13 4:04 AM
                  • 0 Attachment
                    Right, Marc, I see you're a busy man. Hopefully somebody else will
                    feel intrigued by the problem and jump in.



                    On May 13, 12:46 pm, Marc Weber <marco-owe...@...> wrote:
                    > Reread my message. I told you many ways to reach your goal.
                    > One was clear:http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indent...
                    >
                    > I didn't test my mapping, yes - you may have to understand the pieces to
                    > make it work - so if you have trouble understanding the pieces ask
                    > specific questions.
                    >
                    > Thus a great reply would have been
                    > - I didn't understand your sample, I don't know what <c-r> means
                    > - the links you provide didn't help me because ...
                    >
                    > I don't have time to repeat myself.
                    >
                    > Marc Weber

                    --
                    --
                    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

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • Jan Pobrislo
                    I think you might be looking for this: http://www.vim.org/scripts/script.php?script_id=3037 [vim-indent-object : Text Objects based on Indentation Level] Enjoy
                    Message 9 of 13 , May 13 4:48 AM
                    • 0 Attachment
                      I think you might be looking for this:
                      http://www.vim.org/scripts/script.php?script_id=3037
                      [vim-indent-object : Text Objects based on Indentation Level]

                      Enjoy ;-)

                      --
                      --
                      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

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    • Charles Smith
                      Thanks, guys, for all the alternate ways to do what I want to do. And thanks especially to Marc for is tips on how to use the internet (there s one I could
                      Message 10 of 13 , May 14 5:18 AM
                      • 0 Attachment
                        Thanks, guys, for all the alternate ways to do what I want to do. And
                        thanks especially to Marc for is tips on how to use the internet
                        (there's one I could add - if you don't know the answer, that's okay,
                        no stress, you can hit the back button, maybe somebody else knows)

                        But I guess it's just not possible to invoke a vim function from
                        within \{} - or maybe it's a lost art....




                        On 13 Mai, 13:48, Jan Pobrislo <c...@...> wrote:
                        > I think you might be looking for this:http://www.vim.org/scripts/script.php?script_id=3037
                        > [vim-indent-object : Text Objects based on Indentation Level]
                        >
                        > Enjoy ;-)

                        --
                        --
                        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

                        ---
                        You received this message because you are subscribed to the Google Groups "vim_use" group.
                        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                        For more options, visit https://groups.google.com/groups/opt_out.
                      • Ben Fritz
                        ... What gave you that idea? You tried using CTRL-R to get the expression register in a mapping, which can be done, but you forgot to also accept the
                        Message 11 of 13 , May 14 9:44 AM
                        • 0 Attachment
                          On Tuesday, May 14, 2013 7:18:34 AM UTC-5, Charles Smith wrote:
                          >
                          > But I guess it's just not possible to invoke a vim function from
                          >
                          > within \{} - or maybe it's a lost art....
                          >
                          >

                          What gave you that idea?

                          You tried using CTRL-R to get the expression register in a mapping, which can be done, but you forgot to also accept the expression register content to execute the expression by inserting a CTRL-M. So you could either do ^R=somefunc()^M where ^R and ^M are literal CTRL-R and carriage return characters, or even better (in a mapping) use the map syntax <C-R> and <CR>/<C-M>/<Enter>. Even BETTER, is to use an expression mapping. :help :map-<expr>.

                          --
                          --
                          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

                          ---
                          You received this message because you are subscribed to the Google Groups "vim_use" group.
                          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                          For more options, visit https://groups.google.com/groups/opt_out.
                        • Charles Smith
                          Okay, I recognized your point that = is a register and read up on registers, and now I see what you mean. Also, your point about indent(line( . )) was right.
                          Message 12 of 13 , May 14 1:28 PM
                          • 0 Attachment
                            Okay, I recognized your point that = is a register and read up on
                            registers, and now I see what you mean. Also, your point about
                            indent(line('.')) was right. Thank you!

                            map ]0 /^\s\{0,^V^R=indent(line('.'))^V^M}\S^V^M
                            map [0 ?^\s\{0,^V^R=indent(line('.'))^V^M}\S^V^M

                            cts


                            ---------------------------------------------------------
                            http://www.creative-telcom-solutions.de/

                            On 14 Mai, 18:44, Ben Fritz <fritzophre...@...> wrote:
                            > On Tuesday, May 14, 2013 7:18:34 AM UTC-5, Charles Smith wrote:
                            >
                            > > But I guess it's just not possible to invoke a vim function from
                            >
                            > > within \{} - or maybe it's a lost art....
                            >
                            > What gave you that idea?
                            >
                            > You tried using CTRL-R to get the expression register in a mapping, which can be done, but you forgot to also accept the expression register content to execute the expression by inserting a CTRL-M. So you could either do ^R=somefunc()^M where ^R and ^M are literal CTRL-R and carriage return characters, or even better (in a mapping) use the map syntax <C-R> and <CR>/<C-M>/<Enter>. Even BETTER, is to use an expression mapping. :help :map-<expr>.

                            --
                            --
                            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

                            ---
                            You received this message because you are subscribed to the Google Groups "vim_use" group.
                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                            For more options, visit https://groups.google.com/groups/opt_out.
                          Your message has been successfully submitted and would be delivered to recipients shortly.