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

34923Re: [vim] Mapping with count

Expand Messages
  • Charles E. Campbell
    Dec 4, 2002
    • 0 Attachment
      On Wed, Dec 04, 2002 at 11:00:06AM -0500, Benji Fisher wrote:
      > kbosau@... wrote:
      > > I'd like to create a normal mode mapping one
      > > can control by a number that has to be typed
      > > in prior to hitting the mapped key...
      > > for instance should define a normal mode
      > > command '34z'.
      > >
      > > How can I achieve this?
      >
      > fun! F()
      > " Remember to start the function name with a capital!
      > echo "count =" v:count
      > \ ", count1 =" v:count1
      > \ ", prevcount =" v:prevcount
      > endfun

      You'll want to put "range" as a qualifier on the function:

      ---------------------------------------------------------------------
      fun! F() range
      " Remember to start the function name with a capital!
      echo "count =".v:count.", count1 =".v:count1.", prevcount =".v:prevcount
      endfun
      nmap \F :call F()<Cr>
      ---------------------------------------------------------------------

      There's still a problem, however: if the number sent to the function
      is greater than the number of lines in the file, you'll get an
      "E16: Invalid Range" error.

      Regards,
      C Campbell

      --
      Charles E Campbell, Jr, PhD _ __ __
      Goddard Space Flight Center / /_/\_\_/ /
      cec@... /_/ \/_//_/
      PGP public key: http://www.erols.com/astronaut/pgp.html
    • Show all 9 messages in this topic