在Vim CLI中(使用脚本,而不依赖插件),是否可以模仿:
:browse old
并创建一个带编号的菜单(例如脚本)?
答案 0 :(得分:1)
也许您正在寻找inputlist
?
" build your list in whatever way is appropriate for your task
let somelist = map(range(1,&lines-2), '"Item #".v:val')
let numberedlist = map(copy(somelist), 'string(v:key+1).": ".v:val')
let chosen = inputlist(['Pick an item:'] + numberedlist)
if 0 < chosen && chosen < len(somelist)
echo 'User chose item #' . chosen . ': <<<' . somelist[chosen-1] . '>>>'
else
echo 'Invalid selection!'
endif