Vim:你能从另一行中删除一个特定的行号吗? [英] Vim: Can you delete a specific line number from another line?
问题描述
我在第 93 行,意识到我想删除第 89 行.我输入 :d89
希望第 89 行被删除.它没有用.
I was on line 93 and realized I wanted to delete line 89.
I typed :d89
in hopes that line 89 wold be deleted.
It didn't work.
有谁知道完成这种交互的好方法吗?我是一个舒适的 Vim 用户,但(还)还没有开始编写插件......
Does anyone know a good way to accomplish this type of interaction? I am a comfortable Vim user but have not (yet) taken the leap to writing plugins...
谢谢.
推荐答案
冒号命令的地址(例如:行号)在前.
The address of a colon-command (eg: the line number) comes first.
:89d
请注意,这也会导致您导航到更改的位置.可以使用``
跳转回来.
Note that this will also cause you to navigate to the location of the change. You can use ``
to jump back.
如果您希望将其作为单个命令,您可以定义自定义命令.例如:
If you'd prefer to have this be a single command you can define a custom command. eg:
command! -range -nargs=0 Delete <line1>,<line2>d|norm ``
这定义了一个名为 Delete
的命令,该命令删除寻址范围(
),然后向后导航(norm ``
).
This defines a command called Delete
that deletes the addressed range (<line1>,<line2>d
) and then navigates back (norm ``
).
你可以这样称呼它:
:89Delete
您实际上可以使用任何唯一前缀调用它,因此您可以将其归结为:
You can actually invoke it with any unique prefix, so you may be able to get it down to:
:89D
这篇关于Vim:你能从另一行中删除一个特定的行号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!