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

34926Re: [vim] Mapping with count

Expand Messages
  • Benji Fisher
    Dec 4, 2002
      Charles E. Campbell wrote:

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

      Sorry, I forgot about that. I think the right solution is to
      cancel the count:

      fun! EchoCount()
      echo v:count
      nnoremap \F :<C-U>call EchoCount()<CR>

      I use the "nore" form because some people have :cmap's for <C-U>.

      HTH --Benji Fisher
    • Show all 9 messages in this topic