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

Re: Determine the position we left off before moving to the command line

Expand Messages
  • Ben Fritz
    ... I know of no reason whatsoever why line( . ) would not work. I use it all the time. Is your cursor actually on line 1 when you invoke the command? -- --
    Message 1 of 8 , Apr 15 7:34 AM
    • 0 Attachment
      On Sunday, April 14, 2013 7:54:14 AM UTC-5, Axel Bender wrote:
      > I'm searching a way to determine the last cursor position before entering the command line to execute a command defined with
      >
      > :command -range=% aaa call <line1>,<line2>func().
      >
      > If I start from a visual block, I'm able to retrieve that position with line(".") or a:firstline in func().
      >
      > However, if I don't use a range, e.g. if I just enter :aaa, I'm unable able to determine that position as line(".")/a:firstline are both 1.
      >
      > I tried to resort to defining the command like so
      >
      > :command -range=% aaa normal ma| <line1>,<line2>call ... | normal `a
      >
      > but to no avail; func() wouldn't get executed...
      >
      > Any tips?

      I know of no reason whatsoever why line('.') would not work. I use it all the time. Is your cursor actually on line 1 when you invoke the command?

      --
      --
      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.
    • John Little
      ... That doesn t look right; don t you mean ... If you start from visual block , when you type the : vim puts ... on the command-line , and then you type the
      Message 2 of 8 , Apr 15 8:12 PM
      • 0 Attachment
        On Monday, April 15, 2013 12:54:14 AM UTC+12, Axel Bender wrote:

        > :command -range=% aaa call <line1>,<line2>func().

        That doesn't look right; don't you mean

        :command! -range=% Aaa <line1>,<line2>call Func()

        If you "start from visual block", when you type the : vim puts

        :'<,'>

        on the "command-line", and then you type the command name

        :'<,'>Aaa

        if Func is defined with the range attribute, line(".") and a:firstline will be set to that of '<. If you remove the "'<,'>", you've just specified the whole file, so line(".") and a:firstline will be 1.

        You can still get at '< and '> in your function, they will be line("'<") and line("'>"), though that will give the last visual mode used, even if there's no visual mode when the command is invoked.

        HTH, John Little

        --
        --
        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.
      • Axel Bender
        Hm, somehow my last (yesterday evening) post got removed... Anyway. I attached a VimL file which shows the problem (at least here: version 7.3.903, Windows 7,
        Message 3 of 8 , Apr 15 11:42 PM
        • 0 Attachment
          Hm, somehow my last (yesterday evening) post got removed...

          Anyway. I attached a VimL file which shows the problem (at least here: version 7.3.903, Windows 7, 64 bit). Please try to execute :Hi w/o a visual block, the cursor being in line 2.

          --
          --
          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.
        • Anthony Campbell
          I have a lot of abbreviations to automatically correct tyiping errors (hte to the, etc.). It works well for whole words but it would be useful to have it for
          Message 4 of 8 , Apr 16 3:18 AM
          • 0 Attachment
            I have a lot of abbreviations to automatically correct tyiping errors
            (hte to the, etc.). It works well for whole words but it would be useful
            to have it for some teminations, e.g. to catch words ending in *lly
            which I tend to type as *lhy.

            I haven't been able to find such a thing with google. It's no big deal
            but given that one can do practically anything in vim, I thought I'd
            ask.


            --
            Anthony Campbell - ac@...
            http://www.acampbell.org.uk
            http://www.reviewbooks.org.uk
            http://www.skepticviews.org.uk
            http://www.acupuncturecourse.org.uk
            http://www.smashwords.com/profile.view/acampbell
            https://itunes.apple.com/ca/artist/anthony-campbell/id73235412





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