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

how can i go to the function head?

Expand Messages
  • lsyx
    sub some_func() { # I want jump to this line #....some code.............. I am here. #......some code............ } ... Now what can I do to jump to the
    Message 1 of 11 , Dec 30, 2008
    • 0 Attachment
      sub some_func() { # I want jump to this line
      #....some code..............

      I am here.

      #......some code............
      }

      -------------------------
      Now what can I do to jump to the function head?

      Thanks for your time.

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • pansz
      I see # character cannot be used in many commands, how can I escape it? For example: calling an external program with # does not work ... Any hints?
      Message 2 of 11 , Dec 30, 2008
      • 0 Attachment
        I see # character cannot be used in many commands, how can I escape it?

        For example:

        calling an external program with # does not work

        :!echo http://abc.com/index.php#foobar

        abbr with # does not work:

        :iab #inc #include


        Any hints?

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Erik Hahn
        ... A blind guess: try #
        Message 3 of 11 , Dec 30, 2008
        • 0 Attachment
          On Wed, Dec 31, 2008 at 09:50:57AM +0800, pansz wrote:
          >
          >
          > I see # character cannot be used in many commands, how can I escape it?
          >
          > For example:
          >
          > calling an external program with # does not work
          >
          > :!echo http://abc.com/index.php#foobar
          >
          > abbr with # does not work:
          >
          > :iab #inc #include

          A blind guess: try \#
        • pansz
          ... Perhaps I ve not make myself clear: when we vi ~/.bash_profile we will see lots of commands, I defined a map: map 0y$:! 0 which will execute
          Message 4 of 11 , Dec 30, 2008
          • 0 Attachment
            pansz 写道:
            >
            > I see # character cannot be used in many commands, how can I escape it?
            >
            > For example:
            >
            > calling an external program with # does not work
            >
            > :!echo http://abc.com/index.php#foobar
            >
            Perhaps I've not make myself clear:

            when we vi ~/.bash_profile we will see lots of commands, I defined a map:

            map <C-B> 0y$:!<C-R>0<cr>

            which will execute the command in the current line.

            However, if the command in the current line contains # or % in it,
            things will get ruined, is there anyway to convert the output of <C-R>0
            into something which can be used in command line?

            For the following line:

            echo http://abc.com/index.php#foobar

            use the map to 0y$:!<C-R>0<cr> does not work, since the command will try
            to expand # character, and I have no way to quote <C-R>0 output before
            send it to command line.

            Thanks in advance.

            Pan, Shi Zhu

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Gary Johnson
            ... You can use the escape() function to escape certain characters in a string. Your mapping would then become map 0y$:! =escape(@0, # ) See
            Message 5 of 11 , Dec 31, 2008
            • 0 Attachment
              On 2008-12-31, pansz wrote:
              > pansz ??????:
              > >
              > > I see # character cannot be used in many commands, how can I escape it?
              > >
              > > For example:
              > >
              > > calling an external program with # does not work
              > >
              > > :!echo http://abc.com/index.php#foobar
              > >
              > Perhaps I've not make myself clear:
              >
              > when we vi ~/.bash_profile we will see lots of commands, I defined a map:
              >
              > map <C-B> 0y$:!<C-R>0<cr>
              >
              > which will execute the command in the current line.
              >
              > However, if the command in the current line contains # or % in it,
              > things will get ruined, is there anyway to convert the output of <C-R>0
              > into something which can be used in command line?
              >
              > For the following line:
              >
              > echo http://abc.com/index.php#foobar
              >
              > use the map to 0y$:!<C-R>0<cr> does not work, since the command will try
              > to expand # character, and I have no way to quote <C-R>0 output before
              > send it to command line.

              You can use the escape() function to escape certain characters in a
              string. Your mapping would then become

              map <C-B> 0y$:!<C-R>=escape(@0,'#')<cr><cr>

              See

              :help escape()

              Regards,
              Gary


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Charles Campbell
              ... The shellescape() function was designed for this situation. Regards, Chip Campbell --~--~---------~--~----~------------~-------~--~----~ You received this
              Message 6 of 11 , Dec 31, 2008
              • 0 Attachment
                Gary Johnson wrote:
                > On 2008-12-31, pansz wrote:
                >
                >> pansz ??????:
                >>
                >>> I see # character cannot be used in many commands, how can I escape it?
                >>>
                >>> For example:
                >>>
                >>> calling an external program with # does not work
                >>>
                >>> :!echo http://abc.com/index.php#foobar
                >>>
                >> >
                >> Perhaps I've not make myself clear:
                >>
                >> when we vi ~/.bash_profile we will see lots of commands, I defined a map:
                >>
                >> map <C-B> 0y$:!<C-R>0<cr>
                >>
                >> which will execute the command in the current line.
                >>
                >> However, if the command in the current line contains # or % in it,
                >> things will get ruined, is there anyway to convert the output of <C-R>0
                >> into something which can be used in command line?
                >>
                >> For the following line:
                >>
                >> echo http://abc.com/index.php#foobar
                >>
                >> use the map to 0y$:!<C-R>0<cr> does not work, since the command will try
                >> to expand # character, and I have no way to quote <C-R>0 output before
                >> send it to command line.
                >>
                >
                > You can use the escape() function to escape certain characters in a
                > string. Your mapping would then become
                >
                > map <C-B> 0y$:!<C-R>=escape(@0,'#')<cr><cr>
                >
                > See
                >
                > :help escape()
                >
                The shellescape() function was designed for this situation.

                Regards,
                Chip Campbell


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Anton Sharonov
                in normal mode, type: [{ If you are deep in the nested blocks, you can use count with this command: f() { if() { while () { // _ cursor here } } } with cursor
                Message 7 of 11 , Jan 1, 2009
                • 0 Attachment
                  in normal mode, type:

                  [{

                  If you are deep in the nested blocks, you can use count with this
                  command:

                  f() {
                  if() {
                  while () {
                  // _ cursor here
                  }
                  }
                  }

                  with cursor at _ position, use 3[{ to jump to first
                  opening bracket of f(). Another possibility - [m

                  There are a lot of such useful motions. Not complete list:

                  :help [{
                  :help ]}
                  :help [(
                  :help [)
                  :help ]m
                  :help [m
                  :help ]M
                  :help [M
                  :help ]]
                  :help [[

                  --
                  Anton

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • lsyx
                  thanks very much! I have try that out and it works great~ ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the
                  Message 8 of 11 , Jan 2, 2009
                  • 0 Attachment
                    thanks very much! I have try that out and it works great~

                    On Jan 1, 8:28 pm, "Anton Sharonov" <anton.sharo...@...> wrote:
                    > in normal mode, type:
                    >
                    > [{
                    >
                    > If you are deep in the nested blocks, you can use count with this
                    > command:
                    >
                    > f() {
                    >   if() {
                    >     while () {
                    >       // _ cursor here
                    >     }
                    >   }
                    >
                    > }
                    >
                    > with cursor at _ position, use 3[{ to jump to first
                    > opening bracket of f(). Another possibility - [m
                    >
                    > There are a lot of such useful motions. Not complete list:
                    >
                    > :help [{
                    > :help ]}
                    > :help [(
                    > :help [)
                    > :help ]m
                    > :help [m
                    > :help ]M
                    > :help [M
                    > :help ]]
                    > :help [[
                    >
                    > --
                    > Anton
                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • pansz
                    ... The shellescape() function will add single quotes to the string, which ... should work. ... will not run at all. Anyway to disable shellescape() from
                    Message 9 of 11 , Jan 3, 2009
                    • 0 Attachment
                      Charles Campbell 写道:
                      >> You can use the escape() function to escape certain characters in a
                      >> string. Your mapping would then become
                      >>
                      >> map <C-B> 0y$:!<C-R>=escape(@0,'#')<cr><cr>
                      >>
                      >> See
                      >>
                      >> :help escape()
                      >>
                      > The shellescape() function was designed for this situation.
                      >
                      > Regards,
                      > Chip Campbell

                      The shellescape() function will add single quotes to the string, which
                      makes the command unusable, for example:

                      :!echo test

                      should work.

                      :!'echo test'

                      will not run at all.

                      Anyway to disable shellescape() from adding single quotes to the string?
                      Or is it possible to run the string with single quotes?


                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Charles E. Campbell, Jr.
                      ... Hmm, sorry bout that -- in the current case, please try the fnameescape() function. Regards, Chip Campbell
                      Message 10 of 11 , Jan 4, 2009
                      • 0 Attachment
                        pansz wrote:
                        > Charles Campbell 写道:
                        >
                        >>> You can use the escape() function to escape certain characters in a
                        >>> string. Your mapping would then become
                        >>>
                        >>> map <C-B> 0y$:!<C-R>=escape(@0,'#')<cr><cr>
                        >>>
                        >>> See
                        >>>
                        >>> :help escape()
                        >>>
                        >>>
                        >> The shellescape() function was designed for this situation.
                        >>
                        >> Regards,
                        >> Chip Campbell
                        >>
                        >
                        > The shellescape() function will add single quotes to the string, which
                        > makes the command unusable, for example:
                        >
                        > :!echo test
                        >
                        > should work.
                        >
                        > :!'echo test'
                        >
                        > will not run at all.
                        >
                        > Anyway to disable shellescape() from adding single quotes to the string?
                        > Or is it possible to run the string with single quotes?
                        >
                        Hmm, sorry 'bout that -- in the current case, please try the
                        fnameescape() function.

                        Regards,
                        Chip Campbell


                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • pansz
                        ... Hmm, fnameescape makes no difference, it adds backslash to the command and that will also make bash treat the whole command as a file name. for ... doe not
                        Message 11 of 11 , Jan 4, 2009
                        • 0 Attachment
                          Charles E. Campbell, Jr. 写道:
                          >> The shellescape() function will add single quotes to the string, which
                          >> makes the command unusable, for example:
                          >>
                          >> :!echo test
                          >>
                          >> should work.
                          >>
                          >> :!'echo test'
                          >>
                          >> will not run at all.
                          >>
                          >> Anyway to disable shellescape() from adding single quotes to the string?
                          >> Or is it possible to run the string with single quotes?
                          >>
                          > Hmm, sorry 'bout that -- in the current case, please try the
                          > fnameescape() function.
                          >
                          > Regards,
                          > Chip Campbell

                          Hmm, fnameescape makes no difference, it adds backslash to the command
                          and that will also make bash treat the whole command as a file name. for
                          example:

                          :!echo\ test

                          doe not work.

                          my mapping is now:

                          nnoremap <C-K> 0y$:!<C-R>=fnameescape(@0)<cr><cr>

                          When I want to execute commands in a bash shell file, the command line
                          are ready to execute and things like spaces do not need to be quoted.

                          My current solution is the following, I think there should be a better
                          way though.

                          function s:myescape(cmd)
                          let l:esccmd = shellescape(a:cmd, 1)
                          return strpart(l:esccmd, 1, strlen(l:esccmd)-2)
                          endfunction
                          nnoremap <C-K> 0y$:!<C-R>=<sid>myescape(@0)<cr><cr>



                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_use" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        Your message has been successfully submitted and would be delivered to recipients shortly.