Monday, January 23, 2012

Re: Retrieve the argument of a prior Ex mode command (back on-list)

On 01/23/12 14:57, Chris Jones wrote:
> On Wed, Jan 18, 2012 at 08:42:51PM EST, Tim Chase wrote:
>> =================================================
>> let item = histget(getcmdtype(), -1)
>> =================================================
>
> Unless I missed something, I don't think this is going to work, because
> you need a variable to keep track of where you are in the history across
> Alt+period keyboard actions.. (?)

I think the answer to your question is the "-1" in the histget()
call which gets the most recent history entry. If you use a
positive number, it starts from 1 through however many history
items you have. If you use a negative index, it starts indexing
the most-recently-entered-command end of the history (same as for
arrays).

:help history-indexing
:help list-index

The exception I could see would be if you knew that you were only
interested in certain types of Ex commands (in your
contemporaneous message, your "g:cmdlist") and would thus want to
search backwards in your history until you hit such a command and
use *that* command to pull from rather than the most recent Ex
command.

-tim

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

No comments: