I have a key mapped to a command which runs a function, and I would like to detect whether it has been passed a range (prefixed with a count) or not.
The difficultly is that I need to be able to differentiate between 1CTRL E and plain CTRL E.
(CTRL E is actually my interactive buffer selector. But when a range is passed I would like it to act like CTRL ^. That is because I like the functionality of CTRL ^, but it is too much of a stretch for my left hand!)
So I have:
nnoremap <C-E> :JoeysBufferSwitch<Enter>
command! -range JoeysBufferSwitch <line1>,<line2>call JoeysBufferSwitch()
Now I can tell if 5CTRL E was pressed, because a:lastline - a:firstline
will be 4
inside the function.
Unfortunately I cannot detect whether 1CTRL E was pressed or CTRL E was pressed, because in both cases a:lastline == a.firstline
inside the function.
Is there any way I can detect the difference between these two situations, or otherwise behave differently when a count is passed and when a count is not passed?