vim 更改 :x 函数以删除缓冲区而不是 save &辞职
我想在 vim gui-mode 中将 :x
设置为 delete buffer
因为我总是杀死整个 gvim,这有点烦人。我知道我可以使用 if has("gui running")
特别设置 gui 问题,但不知道如何重新映射 :x
提前谢谢
ps.: 也许是标签/term remap
是错误的,但我不知道正确的术语,这就是为什么谷歌根本没有提供任何帮助。
I want to set :x
in vim gui-mode to delete buffer
because I always kill the whole gvim, which is kind of annoying. I know i can specifically set gui problems with if has("gui running")
but don't know how to remap :x
thanks in advance
ps.: maybe the tag/term remap
is wrong but I don't know the correct term, that's why google didn't provide any help at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现最安全的替代方法是使用表达式缩写:
这将确保缩写仅在使用
:x
时扩展为bd
,否则仅扩展为x
。如需更多帮助:
经过进一步检查,Hari Krishna Dara 似乎有一个名为 cmdalias 的插件可以完成此操作。 vim。它使用上述技术的变体。
I find the safest alternative is to use an expression abbreviation:
This will ensure the abbreviation will only be expanded to
bd
when:x
is used otherwise just expand tox
.For more help:
Upon further inspection there appears to be a plugin that does exactly this by Hari Krishna Dara called cmdalias.vim. It uses a variation of the technique above.
这并不像看起来那么容易。
:map
不适用于命令,并且:command
仅接受以大写字母开头的命令。但您可以使用:cabbrev
:更新:
:cmap
可以实际上可以使用::cmap x bd
,但是它无法正常工作:命令中每次出现x
都会立即被bd
替换。编辑:这个问题是Can I (re)map Ex commands in vim的重复项?。
This is not as easy as it looks.
:map
won't work with commands and:command
only accepts commands that start with an uppercase letter. But you can use:cabbrev
:UPDATE:
:cmap
could actually be used::cmap x bd
, but it doesn't work right: each occurrence ofx
in a command is immediately replaced bybd
.EDIT: This question is a duplicate of Can I (re)map Ex commands in vim?.