假设我正在编辑这个 json
{
"a": {"language": "python"},
"b": {},
"c": {"language": "java"},
"d": {"encoding": "utf-16"}
}
我的光标位于
b
的"b": {}
处。我想删除直到当前 {}
块的末尾。所以它看起来像,
{
"a": {"language": "python"},
"
}
看起来有点奇怪。但解释了我想要什么。
我怎样才能在 Vim 中做到这一点?
您可以使用
d]}
。:help ]}
:
*]}*
]} go to [count] next unmatched '}'.
|exclusive| motion.
帮助还说这是该动议的用例之一:
The above four commands can be used to go to the start or end of the current
code block. It is like doing "%" on the '(', ')', '{' or '}' at the other
end of the code block, but you can do this from anywhere in the code block.
对于您的示例,
d]]
也有效。按压起来比较容易。
然而,]}
更好,因为无论 { or }
位于哪一列,它都可以工作。
另一种方法是:
V f ^ } k k d