我已阅读expand
用法,但它没有提供此类功能。
例如,我的tags
文件包含以下内容:
ACTION action/action.h /^}ACTION,*LPACTION;$/;" t line:169
typeref:struct:__anon14
ACTIONDATA action/action.h /^} ACTIONDATA,*LPACTIONDATA;$/;" t line:327
typeref:struct:tagActionData
ADJ_RANGE elo_touch/igslib_elo_touch.cpp 6;" d line:6 file:
ADJ_RANGE micro_touch/igslib_micro_touch.cpp 7;" d line:7 file:
因此,当我输入ADJ
并输入<c-x><c-]>
的快捷方式时,vim将为我完成ADJ_RANGE
。
但该功能在命令行中不受支持。这就是问题所在。
有什么建议吗?
答案 0 :(得分:1)
我不知道我在哪里找到了这个,但如果你安装了bash完成,这个解决方案应该可行。
将以下内容放入~/.bash_completion
_vim_ctags() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case "${prev}" in
-t)
# Avoid the complaint message when no tags file exists
if [ ! -r ./tags ]
then
return
fi
# Escape slashes to avoid confusing awk
cur=${cur////\\/}
COMPREPLY=( $(compgen -W "`awk -v ORS=" " "/^${cur}/ { print \\$1 }" tags`" ) )
;;
*)
# Perform usual completion mode
;;
esac
}
# Files matching this pattern are excluded
excludelist='*.@(o|O|so|SO|so.!(conf)|SO.!(CONF)|a|A|rpm|RPM|deb|DEB|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MP?(E)G|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)'
complete -F _vim_ctags -f -X "${excludelist}" vi vim gvim rvim view rview rgvim rgview gview
如果正确设置了bash完成,则应在shell启动时自动获取此信息。设置完成后,您可以使用
vim -t ADJ<Tab>
自动完成当前目录中的标记。当您使用-t
命令行标志运行vim时,vim将打开该标记。
答案 1 :(得分:0)
您可以使用命令行窗口。以下是:help cmdline-window
的一些摘录:
In the command-line window the command line can be edited just like editing
text in any window. It is a special kind of window, because you cannot leave
it in a normal way.
...
There are two ways to open the command-line window:
1. From Command-line mode, use the key specified with the 'cedit' option.
The default is CTRL-F when 'compatible' is not set.
2. From Normal mode, use the "q:", "q/" or "q?" command.
...
You can now use commands to move around and edit the text in the window. Both
in Normal mode and Insert mode.
...
There are several ways to leave the command-line window:
<CR> Execute the command-line under the cursor. Works both in
Insert and in Normal mode.
因此,您可以打开命令行窗口,根据需要编辑一行,包括使用<C-X><C-]>
完成标记,然后在完成后执行命令。