在Vim中,SuperTab插件是否支持自动完成本地文件名?例如,在C ++程序中,我想输入以下内容:
#include "file
tab
如果本地目录中有一个名为“ fileparser.h”的文件,请让SuperTab自动完成:
#include "fileparser.h
在我当前的配置下,自动完成菜单中唯一的元素是C ++实体,例如类名,没有文件名。
从插件的帮助中:
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
Note: a special value of 'context' is supported which will result in
super tab attempting to use the text preceding the cursor to decide which
type of completion to attempt. Currently super tab can recognize method
calls or attribute references via '.', '::' or '->', and file path
references containing '/'.
let g:SuperTabDefaultCompletionType = "context"
/usr/l<tab> # will use filename completion
因此,是的,存在文件类型补全,但前提是补全基础已经包含斜杠(在您的示例中不是这种情况)。您可以轻松地将插件修改为也接受一个previous #include
,例如这样(倒数第三行是new):
function! s:ContextText() " {{{
let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ?
\ g:SuperTabContextTextFileTypeExclusions : []
if index(exclusions, &ft) == -1
let curline = getline('.')
let cnum = col('.')
let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
if curline =~ '.*/\w*\%' . cnum . 'c' ||
\ curline =~ '#include\s.*\%' . cnum . 'c' ||
\ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\%' . cnum . 'c')
return "\<c-x>\<c-f>"
或者,您可以通过触发内置文件类型的完成<C-x><C-f>
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句