Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vim Autocompletion (v2)

Vim Autocompletion (v2)

Sometimes people miss the IDE-like behavior of getting auto-completion for their code when they switch to Vim, but it doesn't have to be that way: Auto-Completion ("insert expand" mode) opens the door back up to this IDE power tool.

This talk was initially prepared and presented at the June 17, 2015 Baltimore Vim meetup.
The version in this set of slides was revised and presented again at the November 13, 2017 Baltimore Vim meetup.

3ed7378b8a83d2952488d4edcd22c406?s=128

Stephen Belcher

November 13, 2017
Tweet

Transcript

  1. Vim Autocompletion A Whirlwind Introduction

  2. Autocompletion? (Atom IDE, via https://stackoverflow.com/a/37490356)

  3. General Definition • The editor provides, based on context: •

    Suggestions for what to type next • Automatic completion of words/phrases • Documentation or other hints
  4. But Why? • Slow typists have an easier time •

    Lower incidence of typos • You don’t have to remember full APIs in your brain • “Ohh… ahh…” factor
  5. Contrived Example

  6. Contrived Example V ] [

  7. Autocompletion in Vim • Called "Insert Expand" mode • Starts

    in INSERT mode • Initialized with Ctrl-X • Is its own "sub" mode • Has 12 different options for completion method
  8. Using Autocompletion

  9. ^x Using Autocompletion

  10. Using Autocompletion ^x

  11. Using Autocompletion

  12. ^o Using Autocompletion

  13. Using Autocompletion ^o

  14. Using Autocompletion

  15. ^n Using Autocompletion

  16. Using Autocompletion

  17. ^p Using Autocompletion

  18. Autocompletion Modes • Line completion (Ctrl-L) • File Words (Ctrl-N/Ctrl-P)

    • Dictionary Words (Ctrl-K) • Thesaurus Words (Ctrl-T) • Included Words (Ctrl-I) • Tags (Ctrl-]) • Filenames (Ctrl-F) • Definitions/Macros (Ctrl-D) • Vim command-line (Ctrl-V) • User-defined func (Ctrl-U) • Omni Completion (Ctrl-O) • Spelling Suggestions (s)
  19. Nota Bene • OmniCompletion requires ~/.vimrc configuration! • set omnifunc=syntaxcomplete#Complete

  20. File Keyword Shortcut

  21. ^n File Keyword Shortcut

  22. ^n File Keyword Shortcut

  23. File Keyword Shortcut

  24. ^n File Keyword Shortcut

  25. ^n File Keyword Shortcut

  26. Dismissing Preview

  27. Dismissing Preview ^w z

  28. Additional Information • SuperTab - Plugin for mapping to tabs

    • Can “chain” two autocompletion methods together • :help ins-completion • In-depth documentation on the various completion modes
  29. Thanks! http://baltimorevim.org/submit-a-talk.html