gpt4 book ai didi

vim - 如何在命令行中放置占位符

转载 作者:行者123 更新时间:2023-12-04 02:16:31 27 4
gpt4 key购买 nike

例子:在我的 .vimrc

vmap <leader>ii :EasyAlign<Space>((Some hint what to type))

按下<leader>ii后我在我的命令行中得到这个 :EasyAlign<Space>((Some hint what to type))当我开始输入 (new text)它会自动获取而不是 ((Some hint what to type))

类似于 html 中的占位符:

<input type="text" name="fname" placeholder="First name"><br>

最佳答案

据我所知,没有类似的东西。它可以模拟到一定程度,像这样:

function! Prompt(prompt, hint)
echo a:prompt . a:hint
let c = getchar()
if type(c)
" if a special key (like e.g. cursor keys), clear the hint, ignore the key
call feedkeys(a:prompt)
elseif c == 27
" Esc cancels the whole thing, clears the prompt
redraw!
else
" Feed the prompt and the first key to Vim
call feedkeys(a:prompt . nr2char(c))
endif
endfunction

vmap <leader>ii :<C-U>call Prompt(":'<,'>EasyAlign ", "(some hint here)")<CR>

(在映射中,: 单独在 V 模式下会给你 :'<,'> ;所以我们删除带 <C-U> 的范围,并且必须在提示中恢复它)

(编辑以涵盖 getchar 返回类似 <Left> 的字符串的情况)

关于vim - 如何在命令行中放置占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com