Sunday, October 27, 2013

Specifying a count to a normal mode map

Hello,

After a sequence of keys has been nmaped, one can effectively type the
sequence as though it were a normal mode command.

But how can one specify a count to a key sequence that is a nmap? Here's
what I mean:

function! CountTest( the_count )
echo "Count is: [" . a:the_count . "]"
endfunction

:com! -count=1 Lines call CountTest( <count> )
:nnoremap <buffer> <SPACE> :Lines

Now hitting the space bar results in ":Lines" whose output "Count is [1]".

However, hitting 5<space> does _not_ result in ":5Lines" but in
something weird -- ":.,.+4Lines" whose output is some strange number.

Question 1: What needs to be done so that hitting "5<space>" will
result in ":5Lines"?

Question 2: Also, is it possible to get the desired effect without
having to define the command :Lines, i.e., something like:

:nnoremap <buffer> <SPACE> -count=1 :call CountTest( <count> )

Thanks,

--Suresh


--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: