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

Re: how can i go to the function head?

Expand Messages
  • 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 1 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 2 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 3 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 4 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 5 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.