Supertab: autocomplete after a specific word followed by a space

268 Views Asked by At

By default, supertab is inserting a regular tab when the previous character is a space.

I would like to keep this behaviour but with the following exception: if the previous character is a space but the preceding word is import, autocomplete.

For instance (| denotes the cursor position)

  • from numpy import |<tab> should display completions,
  • for |<tab> should insert a tab.

I'm aware of g:SuperTabNoCompleteAfter but I'm not sure how to obtain the desired result.

1

There are 1 best solutions below

0
On

supertab has the ability to consider the preceding text to choose a completion type. You need to teach the plugin about the import context, and configure it to use a custom completion, e.g. user completion (<C-x><C-u>). Then implement the corresponding completion (or find another plugin that already does this), and you should be good.

References