Loading ...
Sorry, an error occurred while loading the content.

Bug with complete()?

Expand Messages
  • Michael Sanders
    Hi, Is this a bug with complete, or am I doing something wrong? ino =CompleteItems() fun! CompleteItems() let word = matchstr(getline( . ),
    Message 1 of 1 , May 24, 2009
    • 0 Attachment
      Hi,

      Is this a bug with complete, or am I doing something wrong?

      ino <f5> <c-r>=CompleteItems()<cr>

      fun! CompleteItems()
      let word = matchstr(getline('.'), '\w\+\%'.col('.').'c')
      let matches = []
      for item in ['foo', 'bar', 'baz', 'foobar']
      if word == '' || item =~ '^'.word
      let matches += [item]
      endif
      endfor
      call complete(col('.') - len(word), matches)
      return ''
      endf

      After loading this into Vim via ~/.vimrc or elsewhere, open a new
      buffer and type:
      foobarbaz
      foo<f5><bs>
      Whole line completion mode is entered, which I do not want. How do I fix this?

      Thanks!

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.