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

Execute -> Search Backwards problem

Expand Messages
  • Tim Johnson
    Using vim 7.1 on kubuntu 7.10: The following snippet of a vim function works as expected elseif fileType == javascript execute / But the search
    Message 1 of 3 , Nov 1, 2008
    • 0 Attachment
      Using vim 7.1 on kubuntu 7.10:

      The following snippet of a vim function works as expected
      elseif fileType == 'javascript'
      execute '/\<function\>'
      But the search backwords equivalent does not work:
      elseif fileType == 'javascript'
      execute '?\<function\>'
      curiously, using ex, as in
      :execute '?\<function\>'
      works.

      Any ideas on what I an doing wrong?
      thanks
      tim (full function code follows)
      "" ----------------------------------------------------------------------------------------------------------
      function! StdNextFunction()
      let fileType = &ft
      if fileType == 'py'
      execute ':call PythonDec("function", 1)<CR>'
      elseif fileType == 'javascript'
      execute '/\<function\>'
      else
      execute 'echo "StdNextFunction() has not (yet) been implemented for this
      file-type"'
      endif
      endfunction
      function! StdPrevFunction()
      let fileType = &ft
      if fileType == 'py'
      execute ':call PythonDec("function", -1)<CR>'
      elseif fileType == 'javascript'
      execute '?\<function\>'
      else
      execute 'echo "StdPrevFunction() has not (yet) been implemented for this
      file-type"'
      endif
      endfunction

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... [...] What it should do is jump to the nearest line containing the word function above the current line. Does the current file contain such a line? If it
      Message 2 of 3 , Nov 1, 2008
      • 0 Attachment
        On 02/11/08 01:23, Tim Johnson wrote:
        > Using vim 7.1 on kubuntu 7.10:
        >
        > The following snippet of a vim function works as expected
        > elseif fileType == 'javascript'
        > execute '/\<function\>'
        > But the search backwords equivalent does not work:
        > elseif fileType == 'javascript'
        > execute '?\<function\>'
        > curiously, using ex, as in
        > :execute '?\<function\>'
        > works.
        >
        > Any ideas on what I an doing wrong?
        > thanks
        > tim (full function code follows)
        [...]

        What it should do is jump to the nearest line containing the word
        "function" above the current line. Does the current file contain such a
        line? If it does, what does your command do? Do you get an error? (Check
        the output of ":messages", because redrawing might erase the message)

        Best regards,
        Tony.
        --
        Although the moon is smaller than the earth, it is farther away.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tim Johnson
        ... at the string function , I have to move the cursor up a line and then re-execute to move to the next previous function. sorry for the confusion - it s all
        Message 3 of 3 , Nov 1, 2008
        • 0 Attachment
          On Saturday 01 November 2008, Tony Mechelynck wrote:

          > > :execute '?\<function\>'

          > [...]
          >
          > What it should do is jump to the nearest line containing the word
          > "function" above the current line. Does the current file contain such a
          > line? If it does, what does your command do? Do you get an error? (Check
          > the output of ":messages", because redrawing might erase the message)
          :-) Actually, it does work, it appears, it is just that when the cursor is
          at the string "function", I have to move the cursor up a line and then
          re-execute to move to the next previous function.

          sorry for the confusion - it's all mine.
          thanks
          tim

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