VimCompletesMe.txt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. *VimCompletesMe.txt* Minimalistic tab completion for Vim.
  2. VIM REFERENCE MANUAL by Akshay Hegde
  3. Help on using VimCompletesMe *VimCompletesMe*
  4. 1. Introduction |VimCompletesMe-intro|
  5. 2. Configuration |VimCompletesMe-configuration|
  6. 3. Frequently Asked Questions |VimCompletesMe-faq|
  7. ==============================================================================
  8. 1. INTRODUCTION *VimCompletesMe-intro*
  9. VimCompletesMe is a tab completion plugin for Vim with minimalism in mind.
  10. It will use Vim's |ins-completion| to provide tab completion and you can
  11. configure VimCompletesMe to use a specific type of completions.
  12. ==============================================================================
  13. 2. CONFIGURATION *VimCompletesMe-configuration*
  14. The following aspects of VimCompletesMe's behavior are configurable using the
  15. following options:
  16. |'b:vcm_tab_complete'| Use a specific type of completion.
  17. |'g:vcm_direction'| Controls the direction of the completion.
  18. |'g:vcm_s_tab_behavior'| Controls the behavior of Shift-Tab.
  19. |'g:vcm_default_maps'| Set up default maps (Tab + Shift Tab)
  20. ------------------------------------------------------------------------------
  21. *'b:vcm_tab_complete'*
  22. Values: string ~
  23. Default: '' ~
  24. Controls the type of completion to use. If empty, the |<Tab>| key will
  25. intelligently (depending on the context) use:
  26. 1. Local keyword completion (|i_Ctrl-X_Ctrl-N|)
  27. 2. File path completion (|i_Ctrl-X_Ctrl-F|)
  28. 3. Omni completion (|i_Ctrl-X_Ctrl-F|)
  29. You can set |b:vcm_tab_complete| to one of the following to use a specific type
  30. of completion:
  31. 1. "dict" - Dictionary completion |i_Ctrl-X_Ctrl-K|
  32. 2. "user" - User-defined completion |i_Ctrl-X_Ctrl-U|
  33. 3. "vim" - Vim command line completion |i_Ctrl-X_Ctrl-V|
  34. 4. "tags" - Tag based completion |i_Ctrl-X_Ctrl-]|
  35. 5. "omni" - Omni completion |i_Ctrl-X_Ctrl-O|
  36. The b:vcm_tab_complete makes a great |:autocmd| as follows:
  37. >
  38. autocmd FileType ruby let b:vcm_tab_complete = "tags"
  39. <
  40. When none of the special completions above get any results, you can press Tab
  41. again to have VimCompletesMe switch the context to keyword completion. In some
  42. situations (like after completing something and then trying the context switch
  43. again without leaving insert mode), you may need a Vim version greater than
  44. 7.3.589 to get the best context switch behavior. The context will be
  45. automatically switched back to the completion set in the |b:vcm_tab_complete|
  46. variable.
  47. NOTE: The "dict" option requires the user to set |'dictionary'| in their
  48. |vimrc| file. In Unix, you can put the following in your ~/.vimrc:
  49. >
  50. set dictionary=/usr/share/dict/words
  51. <
  52. NOTE: The "tags" option will use a tags file generated by |Exuberant_Ctags|
  53. ------------------------------------------------------------------------------
  54. *'g:vcm_direction'*
  55. Values: string ~
  56. Default: 'n' ~
  57. Controls the direction of tab completion. By default, if a popup menu is
  58. opened during completion, the |<Tab>| key will cycle forward through the list.
  59. You can change it to cycle backwards through the list by putting the following
  60. in your |vimrc|:
  61. >
  62. let g:vcm_direction = 'p'
  63. <
  64. ------------------------------------------------------------------------------
  65. *'g:vcm_s_tab_behavior'*
  66. Values: numeric ~
  67. Default: 0 ~
  68. Controls the shift-tab behavior used by VimCompletesMe.
  69. By default, pressing |<S-Tab>| after a space, or a tab will de-indent the
  70. current line.
  71. If you change this option to 1, |<S-Tab>| will work just like |<Tab>|.
  72. You can change this variable by putting the following in your |vimrc|:
  73. >
  74. let g:vcm_s_tab_behavior = 1
  75. <
  76. ------------------------------------------------------------------------------
  77. *'g:vcm_default_maps'*
  78. Values: numeric ~
  79. Default: 1 ~
  80. Set up mappings for Tab and Shift-Tab. If you would like to use your
  81. own mappings, unset this variable by putting the following in your |vimrc|:
  82. >
  83. let g:vcm_default_maps = 0
  84. <
  85. ==============================================================================
  86. 3. FREQUENTLY ASKED QUESTIONS *VimCompletesMe-faq*
  87. 1. When the popup menu is opened, how can I make the Enter key select the ~
  88. completion entry instead of creating a new line? ~
  89. Solution: Just make a mapping like the following, in your |vimrc|:
  90. >
  91. inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  92. <
  93. 2. When pressing the Tab key, why is the the last popup item selected? ~
  94. This is because VimCompletesMe is invoking |i_Ctrl-P| by default for you.
  95. Pressing the Tab key will then cycle forwards the list, so some users are
  96. confused that it takes two Tab presses to jump to the first item in the list.
  97. However, this behavior is the default Vim behavior, and VimCompletesMe agrees
  98. with it. Invoking |i_Ctrl-P| instead of |i_Ctrl-N| is done because it is more
  99. likely that the keyword you are trying to complete is before the current
  100. cursor position. When the Tab key is pressed when the popup menu is open,
  101. VimCompletesMe simply uses Ctrl-N to advance to the next item in the popup
  102. menu. If you would like VimCompletesMe to invoke |i_Ctrl-N| instead, see the
  103. |'g:vcm_direction'| option.
  104. It is also useful to check out the "longest" attribute of the |'completeopt'|
  105. option. Setting the following in your |vimrc| will insert the longest matching
  106. string and then popup the completion item, so you will always start at the
  107. head of the popup menu list:
  108. >
  109. set completeopt+=longest
  110. <
  111. 3. How do I make VimCompletesMe work with various snippet engines? ~
  112. A simple solution is to ensure that the Tab and Shift-Tab keys do not conflict
  113. with any other plugins. Thus, you can either disable VimCompletesMe's
  114. |vcm_default_maps| option or use a different forward and backward triggers for
  115. the snippet engines.
  116. For the first case, simply assign a different key to act as the Tab key for
  117. <Plug>vim_completes_me_forward, or the Shift-Tab key for
  118. <Plug>vim_completes_me_backward functions.
  119. For the second case, simply assign different keys to act as the snippet
  120. engines forward and backward triggers. A suggestion would be to map `<C-j>`
  121. and `<C-k>` in insert mode. Note that while |i_Ctrl-j| does nothing useful in
  122. insert mode, you might be using |i_Ctrl-k| for digraphs. These keybinds are
  123. merely suggestions.
  124. @sunaku from Github has a great solution to make VimCompletesMe work with
  125. Neosnippet. See
  126. https://github.com/ajh17/VimCompletesMe/issues/12#issuecomment-94115124
  127. ------------------------------------------------------------------------------
  128. Template From: https://github.com/dahu/Area-41/
  129. vim:tw=78:et:ft=help:norl: