In principle it should be possible to write a script for this in vim,
though I foresee some problems.
1. Doing it the way described above, would imply actual inserting
of contents into the buffer and would have undesirable sideeffects
( like popping up in the undo tree )
2. Using the popupmenu you'll have to hack around it's internal
state-machine
and peculiar triggering mechanism ( probably per feedkeys() )
3. Other ways to make the suggestion to the user include the commandline
and the statusline. This would cause the least problems, but may be
undesirable.
You can simulate 2. with this code :
augroup foo
au!
au CursorMovedI,InsertEnter * if search('\k\{2,}\%#\k\@!','ncb') |
\ call feedkeys("\<c-n>\<c-p>","t") | endif
augroup END
inoremap <expr><cr> pumvisible()?"\<c-n>\<c-y> ":"\<cr>"
Pressing return-key will accept the first match.
Be ready to exit the editor.
-ap
Very nifty ap.
I created a wrapper around this so you can turn it on or off on a per
buffer basis.
I also created a Vim Tip on the wiki for this:
http://vim.wikia.com/wiki/Automatic_type_along_completion_(typeahead)
Problem is, I can't make the tip format correctly.
John, can you help me fix that up?
Dave
It was an easy fix. In the future, just use <pre> tags instead of the
<code> tags you tried.
I know <code> is probably the "correct" semantic markup, but to get
the desired look on the wiki, use <pre> instead.
Thanks for the contribution!
Thanks Ben.
I noticed you also used the # instead of the 1., 2.
Good tips.
Dave
Yes, that's wiki markup, as on the Wikipedia:
HTML markup:
<ol>
<li>Line 1</li>
<li>Line 2</li>
<li>Line 3</li>
</ol>
Wiki markup:
# Line 1
# Line 2
# Line 3
Result in both cases:
1. Line 1
2. Line 2
3. Line 3
Use multiple # for additional sublevels; and similarly, * ** etc. for
bulleted lists (at successive levels of nesting), : :: etc. for
successive indents with neither numbers nor bullets.
The Vim wiki uses the same software as the Wikipedia so if you know the
one you can write up articles for the other.
Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
59. Your wife says communication is important in a marriage...so you buy
another computer and install a second phone line so the two of you can
chat.
Ben beat me...
But I will take this opportunity to whinge to you and Sightless. When you logged on
at the wiki, did you see an annoying bar at the top which said you had new messages?
I guess we are all trained to NOT "click here to claim your prize", so perhaps
people are ignoring it.
If there is no such "you have new messages" bar, you should be able to find a "my
talk" link next to your log-in name, which is at the top of the screen, on the right
(in the monobook skin that I have chosen in "my preferences").
Anyway, on your talk page is a message. Among other things it suggests that you
create your user page. I'm just telling you all this so I know that you have seen
it. Thanks for the new tip!
John
Please don't advertise this as a working solution, because it is not.
-ap
-T
I did see it a few weeks ago, and I did read it, and I considered making
a user page, but when I looked at the sort of things to put on it, I
couldn't really think of anything I wanted to put on one of my own, so I
didn't. I did appreciate the message, though. Thanks, John.
Cheers,
Ben.
Someone posted a link (on the wiki) to a script on vim.org, maybe that is
already a good, "working" solution.
-ap
Fair enough. I imagine that most people on a list like this are not used to putting
a "look at me" page on the web. However, I would encourage people to think about
making at least a very simple page, something like this:
---begin---
I've been using Vim for years, mostly for C programming.
---end---
The benefit of such a page, despite saying essentially nothing, is that it indicates
that the editor has worked out how to make their user page (and doesn't need help to
do it), and it suggests that the editor will read a message on their talk page (or
at least, the editor would know how to read their talk page!). Such talk is pretty
rare, but it can be useful to contact someone with a comment. You don't need a user
page for that to work, but the poster is filled with doubt regarding whether the
user would even notice such a comment. Also, if we have lots of user pages, other
people may be encouraged to join in.
If an editor gets really helpful and joins in a discussion (e.g. at the New Tips
page), the editor should finish their comment with "~~~~" for a signature consisting
of username/date. The signature contains a link to the user's page, and that link is
red if the page does not exist. Red links are a bit unsettling for the sensitive
among us.
You can browse the following to see active users (this is cached, and can sometimes
fail to show a user who has been active for a few weeks; the list is updated when
the Wikia server gets around to it):
http://vim.wikia.com/wiki/Special:Listusers
John