作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
例子:在我的 .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/
我是一名优秀的程序员,十分优秀!