On 19/01/10 02:53, KKde wrote:
completion-config.file
word path.txt
word2 path2.txt
You want to have a look at
:h complete-functions
:h readfile (how to read a file and get a list of lines)
:h filter( (remove the lines not matching your word by regex)
:h matchstr (match the file path ...)
Thanks..with readfile i'm able to write a workable solution.
readfile func reads the entire file into memory. i like to know, will
the memory be released once the auto complete function completes?
Regards,
kkde
It all depends on how you use it.
If you use, for instance, ":let s:file = readfile(foobar)", then the
script-local variable s:file contains the entire file, and won't be
removed from memory until or unless you ":unlet" it (from the same
script, for an s: variable). OTOH, if you pass readfile(foobar) as an
argument to a function, or ":let" a function-local variable to it, then
it may become available for "automatic garbage collection" when the
function returns, unless maybe references to the list or to some of its
components are still in use at that time.
Also, beware that :readfile reads the file with no charset recognition.
If it can contain anything but 7-bit US-ASCII it might be more prudent
to read it into a buffer with ":sview some/path/to/filename.ext" and
close it with ":q" (or even ":bw") when no more needed.
Best regards,
Tony.
--
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.
-- George Bernard Shaw
--
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
To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or
reply to this email with the words "REMOVE ME" as the subject.