Monday, January 23, 2012

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

On Wed, Jan 18, 2012 at 08:42:51PM EST, Tim Chase wrote:

[..]

> =================================================
> function! PreviousTail()
> let item = histget(getcmdtype(), -1)
> let patterns = [
> \
> '^\%([GvV]\|g\%[lobal]\|s\%[ubstitute]\)\(\W\)\%(\1\@!.\|\\\1\)\1\(.*\)',
> \ '^.* \(.*\)',
> \ ]
> for pat in patterns
> let matches = matchlist(@:, pat)
> if len(matches)
> for i in range(1,9)
> if len(matches[-i])
> return matches[-i]
> endif
> endfor
> endif
> endfor
> return item
> endfunction
>
> cnoremap <expr> <m-.> PreviousTail()
> =================================================

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.. (?)

Perhaps Vim should provide histgetprev() & histgetnext() (and possibly
histend() & histstart()) builtin functions to retrieve/scroll history
contents in the first place?

Not sure it's worth an enhancement feature request, though..

CJ

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